{"id":15504,"date":"2019-02-20T07:47:08","date_gmt":"2019-02-20T07:47:08","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15504"},"modified":"2026-03-10T09:30:52","modified_gmt":"2026-03-10T09:30:52","slug":"how-to-install-and-use-linux-screen","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-install-and-use-linux-screen","title":{"rendered":"How to use Linux screen for effective terminal management"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Linux Screen is a Terminal multiplexer that lets users create multiple virtual shell sessions in their system. It saves the current process in Terminal, keeping it running even after the user disconnects from the server.<\/p><p>Also known as GNU Screen, this tool is especially useful when managing remote systems like a virtual private server (VPS) hosting via SSH. Its capability to create multiple Terminal sessions helps users multitask and collaborate easily.<\/p><p>In this article, we will explain how to install Linux Screen and its command examples. You will also learn several tips for using and pairing it with our AI assistant, Kodee, to improve Linux terminal productivity.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n<div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What Is Linux Screen?<\/h2>\n                    <p>Linux Screen is a command-line utility for creating and managing multiple Terminal sessions. It lets you create a virtual shell whose process remains running even after the user disconnects from the server.<br>\nWith Screen, VPS users can leave an SSH session and continue where they left off. It is available in most Linux distributions, including Debian and RHEL-based operating systems.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-the-linux-screen-command\">How to Install The Linux Screen Command<\/h2><p>After <a href=\"\/ca\/tutorials\/getting-started-with-vps-hosting\">setting up your VPS<\/a>, connect to the remote server via SSH using <strong>PuTTY<\/strong> or <strong>Terminal<\/strong>. If you use Hostinger, use our<strong> Browser Terminal<\/strong> on hPanel to run <a href=\"\/ca\/tutorials\/linux-commands\">Linux commands<\/a> directly from your web browser.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a05efed\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"378\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/10\/VPS-manage-browser-terminal-1024x378.png\" alt=\"VPS Overview hPanel dashboard, highlighting Browser terminal\" class=\"wp-image-125742\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Enter the SSH login credentials. In hPanel, this information is located in the<strong> VPS overview<\/strong> menu. Once connected, run the following command to check whether your system has the GNU Screen utility installed:<\/p><pre class=\"wp-block-preformatted\">screen --version<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a0613f5\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"50\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/terminal-shows-installed-screen-version.png\" alt=\"Terminal shows the currently installed GNU Screen version\" class=\"wp-image-94632\"  sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>If Terminal returns the version number, your system already has Screen installed. Otherwise, run these commands to install Screen in <strong>Ubuntu 22.04 <\/strong>or other <strong>Debian derivatives<\/strong>:<\/p><pre class=\"wp-block-preformatted\">sudo apt update<\/pre><pre class=\"wp-block-preformatted\">sudo apt install screen<\/pre><p>To install Screen in <strong>RHEL derivatives<\/strong> like <strong>CentOS<\/strong>, use <strong>dnf <\/strong>or <strong>yum<\/strong>. For newer versions like <strong>CentOS 8 <\/strong>or later, use the following <strong>dnf <\/strong>commands:<\/p><pre class=\"wp-block-preformatted\">sudo dnf update<\/pre><pre class=\"wp-block-preformatted\">sudo dnf install screen<\/pre><p><div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Learn more about the <a href=\"\/ca\/tutorials\/best-linux-distro\">best Linux Distributions<\/a> for your VPS.<\/p>\n                <\/div>\n\n\n\n<\/p><p>Alternatively, install Screen from its repository. Here&rsquo;s how to do so in <strong>Ubuntu 22.04<\/strong>:<\/p><ol class=\"wp-block-list\">\n<li>Run these commands to install GCC and the ncurses library. If you already have them, skip this step.<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt -y install gcc<\/pre><pre class=\"wp-block-preformatted\">sudo apt -y install libncurses-dev<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Fetch the Screen installation file from the repository using the <strong>wget <\/strong>command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">wget https:\/\/ftp.gnu.org\/gnu\/screen\/screen-4.9.1.tar.gz<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Unpack the file using the <a href=\"\/ca\/tutorials\/linux-tar-command-with-examples\"><strong>tar <\/strong>command<\/a>.<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">tar -xvf screen-4.9.1.tar.gz<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Navigate to the unpacked directory using <strong>cd<\/strong>:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">cd screen-4.9.1<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Run the installation using this command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">.\/configure<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Enter this command to build and compile GNU Screen:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">make<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Install Screen on your system with the following command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo make install<\/pre><ol start=\"8\" class=\"wp-block-list\">\n<li>Check the Linux Screen version to verify if the installation is successful.<\/li>\n<\/ol><h2 class=\"wp-block-heading\" id=\"h-linux-screen-usage-examples\">Linux Screen Usage Examples<\/h2><p>In this section, we will explore some Linux Screen commands for various usages to help you understand the tool.<\/p><h3 class=\"wp-block-heading\">Launch a New Screen Session<\/h3><p>To start a session, enter the <strong>screen<\/strong> command and hit space to close the welcome message. If you don&rsquo;t specify the session name, Screen will automatically set it as <strong>tty1.hostname<\/strong>.<\/p><p>For easier identification, give your session a custom name using the<strong> -S <\/strong>option. For instance, use this Screen command to start a new session named <strong>session1<\/strong>:<\/p><pre class=\"wp-block-preformatted\">screen -S session1<\/pre><p>To quit Screen, enter the <strong>exit<\/strong> command. Terminal will output the following message, indicating you have returned to the original shell:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a063dab\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"789\" height=\"54\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/terminal-screen-termination-message.png\" alt=\"Terminal prints a message indicating that Screen is terminating\" class=\"wp-image-94633\"  sizes=\"auto, (max-width: 789px) 100vw, 789px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\">Create a New Terminal Window<\/h3><p>Press <strong>Ctrl-a + c<\/strong> in a session to create a new Screen window with a shell. This separate command prompt helps streamline Linux Terminal multitasking and improves process isolation.<\/p><p>To create more Terminal instances, repeat the shortcut as needed. Enter the <strong>exit <\/strong>command or press the <strong>Ctrl-a + k <\/strong>shortcut to close the current window.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> To use Linux Screen shortcuts, release <strong>Ctrl + a<\/strong> before pressing the next key. The commands are case-sensitive, so ensure you correctly enter the uppercase or lowercase character letters.<\/p><\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\">Switch Between Windows<\/h3><p>Use keyboard shortcuts to switch between windows in a session:<\/p><ul class=\"wp-block-list\">\n<li><strong>Ctrl-a + n <\/strong>&ndash; cycle to the next screen window.<\/li>\n\n\n\n<li><strong>Ctrl-a + p <\/strong>&ndash; move to the previous window.<\/li>\n\n\n\n<li><strong>Ctrl-a + ID<\/strong> <strong>number <\/strong>&ndash; switch to any Screen window.<\/li>\n\n\n\n<li><strong>Ctrl-a +<\/strong> <strong>1 <\/strong>&ndash; switch to the second Terminal. The numbering starts from zero.<\/li>\n\n\n\n<li><strong>Ctrl-a<\/strong> &ndash; press it twice to quickly toggle between the current and previous windows. It will move you directly to the last accessed Terminal window.<\/li>\n<\/ul><h3 class=\"wp-block-heading\">View and Select From a List of All Active Windows<\/h3><p>Instead of switching back and forth between multiple Screen windows, press <strong>Ctrl-a + &ldquo;<\/strong> to list all of them. Navigate the list using the <strong>arrow keys<\/strong> and press <strong>Enter<\/strong> to access the highlighted one.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a066659\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"131\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/terminal-lists-all-running-screen-windows-in-a-session.png\" alt=\"Terminal lists all the running Screen windows in a session\" class=\"wp-image-94634\"  sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Linux Screen also lets you move between Screen windows using their name. To do so, press <strong>Ctrl-a +<\/strong> <strong>&lsquo;<\/strong> and enter its name.<\/p><p>To change a window&rsquo;s name, navigate to the Terminal instance in question and press <strong>Ctrl-a + : <\/strong>to enable the command mode. Enter the following to change its name:<\/p><pre class=\"wp-block-preformatted\">title \"Screen Window Name\"<\/pre><h3 class=\"wp-block-heading\">Detach From a Screen Session<\/h3><p>To detach from a Screen session and return to the original Terminal shell, press the <strong>Ctrl-a + d<\/strong> shortcut. You can do so from any screen window within that session.<\/p><p>The detached session keeps its processes and windows running in the background. If you run an application in this session, it will remain active even after disconnecting from the server.<\/p><h3 class=\"wp-block-heading\">List All Active Screen Sessions<\/h3><p>To list all active sessions, run the following Screen command in your original Terminal shell:<\/p><pre class=\"wp-block-preformatted\">screen -ls<\/pre><p>It will show all the running Screen sessions, their detachment statuses, names, and process IDs. This information is used for reattaching to the Screen session.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a0691fa\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"919\" height=\"134\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/terminal-lists-all-running-sessions.png\" alt=\"Terminal lists all the running Screen sessions\" class=\"wp-image-94635\"  sizes=\"auto, (max-width: 919px) 100vw, 919px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\">Reattach to a Detached Screen Session<\/h3><p>To reattach to a running Screen session, run the following command in your main system Terminal:<\/p><pre class=\"wp-block-preformatted\">screen -r ID-name<\/pre><p>Replace <strong>ID-name <\/strong>with the actual Screen session ID or name. For example, you can run either Screen command to reattach to the <strong>1268.session1 <\/strong>session:<\/p><pre class=\"wp-block-preformatted\">screen -r 1268<\/pre><pre class=\"wp-block-preformatted\">screen -r session1<\/pre><h3 class=\"wp-block-heading\">Send Commands to a Detached Session<\/h3><p>Linux Screen lets you run commands to a detached session without reattaching and opening it. To do so, use this syntax:<\/p><pre class=\"wp-block-preformatted\">screen -S session-name-or-id -X -p 0 command<\/pre><p>Replace <strong>0 <\/strong>with the Terminal window number. For example, we&rsquo;ll run the following command to echo a message in the<strong> hostinger <\/strong>session&rsquo;s first Terminal window:<\/p><pre class=\"wp-block-preformatted\">screen -S hostinger -X -p 0 echo \"Test message\"<\/pre><p>The virtual Screen session won&rsquo;t produce an output if the command runs properly. Rather, it will print error messages and bash script outputs.<\/p><h3 class=\"wp-block-heading\">Run Long-Running Processes<\/h3><p>Screen keeps long-running processes in the background, allowing you to continue where you left off after disconnecting from the current SSH session. This feature is useful for executing bash scripts, which may take a long time to run.<\/p><p>To do so, create a new Screen session, run the script in the virtual Terminal, and detach from it. Alternatively, execute it via the main shell using the <strong>stuff <\/strong>command:<\/p><pre class=\"wp-block-preformatted\">screen -S session -X -p 0 stuff \"cd \/script\/directory\/path; .\/script.sh\"$(printf r)<\/pre><p>In addition to bash scripts, this feature keeps hosted applications active in the background. For example, it allows your <a href=\"\/ca\/vps\/minecraft-hosting\">Linux Minecraft server<\/a> to remain accessible after you quit the session.<\/p><p>You can also run the <a href=\"\/ca\/tutorials\/how-to-use-tail-command\/\">tail command<\/a> with an <strong>-f<\/strong> option. Since Screen outputs the new log entries in a virtual session, you can use the main Terminal shell for other tasks. <\/p><p>To monitor the task in the virtual session, install and enable a process tracker tool like <strong>htop<\/strong>. To do so, run the following commands sequentially:<\/p><pre class=\"wp-block-preformatted\">sudo apt install htop<\/pre><pre class=\"wp-block-preformatted\">screen -r session-name<\/pre><pre class=\"wp-block-preformatted\">htop<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a06b78b\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"957\" height=\"526\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/htop-user-interface-in-terminal.png\" alt=\"The htop user interface in Linux Terminal\" class=\"wp-image-94636\"  sizes=\"auto, (max-width: 957px) 100vw, 957px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\">Remote Collaboration and Pair Programming<\/h3><p>Linux Screen lets users create a shared Terminal session to simplify collaboration and task management. An isolated session also makes the command-line interface less cluttered, so users can easily check the command history.<\/p><p>To connect to an existing shared Linux Screen session, access the server via SSH and attach using this command:<\/p><pre class=\"wp-block-preformatted\">ssh user@vps-ip -t \"screen -r session-name\"<\/pre><p>For an SSH client, run the<strong> screen<\/strong> command separately after logging in to the server. To simplify remote collaboration with Screen, create several separate Terminal instances in a window by pressing <strong>Ctrl-a + S<\/strong>.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Enabling session sharing in Linux lets multiple users run commands in your server. To improve VPS security, enable the Screen password by entering <strong>Ctrl-a + :password<\/strong> in the session.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\">Run Multiple Tasks Simultaneously<\/h3><p>You can create multiple Screen sessions and windows, each running a separate process. This simplifies multitasking and improves process isolation and resource efficiency.<\/p><p>Since each task runs independently, you can terminate unresponsive ones without affecting other processes. Disabling them also lets you reallocate server resources to run another hardware-intensive task.<\/p><p>Running tasks in isolated Terminals also simplifies the log data for easier troubleshooting and debugging. To create a logged Screen session, use the following command:<\/p><pre class=\"wp-block-preformatted\">screen -L -S session-name<\/pre><h2 class=\"wp-block-heading\" id=\"h-linux-screen-tips-for-effective-usage\">Linux Screen Tips for Effective Usage<\/h2><p>In this section, we will explain several Linux Screen best practices to help you efficiently use it for VPS management.<\/p><p><strong>Customize Screen Settings Through .screenrc<\/strong><\/p><p>To modify Linux Screen settings, edit the user&rsquo;s configuration file in the ~\/<strong>.screenrc<\/strong> directory. Since Screen doesn&rsquo;t provide this file by default, create it by entering this command as root:<\/p><pre class=\"wp-block-preformatted\">cd ~; nano .screenrc<\/pre><p>In the text editor, write the Screen configurations and press <strong>Ctrl-x + y <\/strong>to save the changes. You can tweak various settings, including:<\/p><ul class=\"wp-block-list\">\n<li><strong>Escape <\/strong>&ndash; modifies the shortcut to send commands to Screen. The default one is <strong>Ctrl-a<\/strong>.<\/li>\n\n\n\n<li><strong>Startup program<\/strong> &ndash; sets commands or scripts to automatically run when you start Screen.<\/li>\n\n\n\n<li><strong>Keybindings <\/strong>&ndash; alters the keyboard combinations for Screen commands and actions.<\/li>\n\n\n\n<li><strong>Number<\/strong> &ndash; changes the Terminal window&rsquo;s numbering setting. You can set it off or start the window with another number.<\/li>\n\n\n\n<li><strong>Startup message<\/strong> &ndash; disables or enables the welcome message shown after starting a Screen session.<\/li>\n<\/ul><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Since the <strong>.screenrc<\/strong> file is hidden, use the <strong>ls -a<\/strong> command in the directory to check whether it is successfully created.<\/p>\n                <\/div>\n\n\n\n<\/p><p>For example, add the following snippet to disable the welcome message and change the default <strong>ctrl-a <\/strong>prefix key:<\/p><pre class=\"wp-block-preformatted\">#Disable the welcome message\nstartup_message off\n#Change prefix to alt-tab\nescape ^Ii<\/pre><p><strong>Use Meaningful Window Titles for Easier Session Navigation<\/strong><\/p><p>Having multiple screen sessions running complicates navigation, especially when they share the same name. To simplify the task, we recommend giving them a descriptive name, like the running process or script.<\/p><p>In addition to using the <strong>-S<\/strong> option to start a new session with a custom name, Screen lets you rename existing ones. To do so, attach to the session in question, press the <strong>Ctrl-A + :<\/strong> shortcut, and enter the new name.<\/p><p>If your Screen session has multiple windows, set their default name using the <strong>-t<\/strong> option. Here&rsquo;s the command syntax:<\/p><pre class=\"wp-block-preformatted\">screen -S Session-name -t Window-title<\/pre><p>Running the command in the main Terminal will create a new session called <strong>Session-name<\/strong>. When you create a new window in it, the name will be set to <strong>Window-title<\/strong> by default.<\/p><p><strong>Employ Split-Screen Functionality for Multitasking<\/strong><\/p><p>GNU Screen lets users split a Terminal window manager into separate regions with independent shells. It makes multitasking easier as they can move between different Terminals while keeping all of them visible.<\/p><p>Press <strong>Ctrl-a + S<\/strong> to split the window horizontally and <strong>Ctrl-a + | <\/strong>to separate it vertically. Using the same commands, you can separate the new region further to create a smaller Terminal window.<\/p><p>By default, the new region is an unusable, blank window. To activate it, move to the new region using <strong>Ctrl-a + tab<\/strong> and create a new window by pressing <strong>Ctrl-a + C<\/strong>. Repeat this process for all regions.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a06de9c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"962\" height=\"528\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/02\/linux-screen-split-window-functionality.png\" alt=\"The split-window functionality in Linux Screen\" class=\"wp-image-94637\"  sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Alternatively, navigate by changing the input focus via the command mode. For example, enter <strong>Ctrl-a + :focus right<\/strong> to switch to the region on the right side of your current window.<\/p><p>You can also rebind the Terminal window navigation commands by editing the <strong>.screenrc <\/strong>file. For example, this snippet lets you switch regions by pressing <strong>Ctrl-a + navigation arrow<\/strong>:<\/p><pre class=\"wp-block-preformatted\">#Rebind the split-window navigation shortcuts\nbind ^[[A focus up\nbind ^[[A focus up\nbind ^[[B focus down\nbind ^[[C focus left\nbind ^[[D focus right<\/pre><p><strong>Use Keyboard Shortcuts<\/strong><\/p><p>Understanding Linux Screen&rsquo;s keyboard shortcuts is crucial for using and navigating the tool. Some of the essential key combinations are:<\/p><ul class=\"wp-block-list\">\n<li><strong>Ctrl-a + c<\/strong> &ndash; create a new window.<\/li>\n\n\n\n<li><strong>Ctrl-a + p <\/strong>and<strong> n<\/strong> &ndash; move to the previous and next window.<\/li>\n\n\n\n<li><strong>Ctrl-a + w<\/strong> &ndash; display the Terminal window list.<\/li>\n\n\n\n<li><strong>Ctrl-a + A<\/strong> &ndash; rename the current window.<\/li>\n\n\n\n<li><strong>Ctrl-a + : <\/strong>&ndash; enter the command mode.<\/li>\n\n\n\n<li><strong>Ctrl-a + x<\/strong> &ndash; close the current window.<\/li>\n\n\n\n<li><strong>Ctrl-a + a <\/strong>&ndash; cancel the initial <strong>Ctrl-a <\/strong>shortcut.<\/li>\n<\/ul><p>Refer to the <a href=\"https:\/\/www.gnu.org\/software\/screen\/manual\/screen.html\" target=\"_blank\" rel=\"noreferrer noopener\">GNU Screen manual<\/a> for the comprehensive command and shortcut list. To help you remember the combinations, change the default key bindings based on your preference by editing the<strong> .screenrc <\/strong>file.<\/p><h2 class=\"wp-block-heading\" id=\"h-using-kodee-with-linux-screen\">Using Kodee with Linux Screen<\/h2><p>Hostinger&rsquo;s VPS AI integration simplifies server management with Linux Screen. <strong>Kodee<\/strong>, our AI Assistant, lets you enter simple prompts to generate Screen-related commands, scripts, and step-by-step instructions tailored to your server setup.<br><\/p><p data-start=\"314\" data-end=\"375\" data-is-last-node=\"\" data-is-only-node=\"\"><\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1e1a0703de\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/10\/hpanel-kodee-ai-assistant-screen-1024x555.png\" alt=\"Kodee AI assistant screen on hPanel.\" class=\"wp-image-117102\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Kodee is available with all of <a href=\"\/ca\/vps-hosting\">Hostinger&rsquo;s VPS packages<\/a>. To access it, log in to <strong>hPanel <\/strong>and click <strong>VPS <\/strong>on the top menu. Select the server from the list and click <strong>Kodee<\/strong> from the sidebar.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> Due to AI&rsquo;s limitations, the tool may give outdated or inaccurate information. Always double-check the outputs to make sure they are still accurate.<\/p><\/div>\n\n\n\n<\/p><p>Enter your prompts or questions into the field and press <strong>Send. <\/strong>For example, you can ask how to install and use GNU Screen in your system:<\/p><ul class=\"wp-block-list\">\n<li>I am using an <strong>Ubuntu 22.04 <\/strong>VPS. Can you give me the steps to install Linux Screen?<\/li>\n\n\n\n<li>I have installed Linux Screen in my system. Can you explain how to use it?<\/li>\n\n\n\n<li>Can you give me a command to start a new Linux Screen session?<\/li>\n\n\n\n<li>Please generate a command to run a bash script in a detached session from my main Terminal.<\/li>\n\n\n\n<li>I want to change my Linux Screen&rsquo;s keybindings. Can you generate configuration settings for the <strong>.screenrc <\/strong>file?<\/li>\n<\/ul><p>Ensure your AI prompts for VPS management are clear and specific to allow the assistant to generate accurate results. For instance, specify your VPS operating system since Linux commands vary depending on the distribution.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Linux Screen is a multiplexer that lets you create multiple virtual Terminal sessions in your system. It keeps the session&rsquo;s process running in the background even when the user disconnects from the server.<\/p><p>To install this tool in your system, use the package manager command utility like<strong> apt<\/strong>, <strong>yum<\/strong>, or <strong>dnf<\/strong>. Alternatively, download it from the official repository using the <strong>wget <\/strong>command. Once installed, run the <strong>screen <\/strong>command to start a new session.<\/p><p>In the new session, press <strong>Ctrl-a + c <\/strong>to create new Screen windows and <strong>Ctrl-a + a<\/strong> to switch between them. Use the<strong> Ctrl-a + d <\/strong>shortcut to detach from Terminal sessions and the <strong>Screen -r <\/strong>command to reattach.<\/p><p>Screen lets you run commands remotely in the detached session using the<strong> -X<\/strong> option, which is commonly used for long processes like script execution. It also supports a split-screen Terminal, which simplifies multitasking and collaboration.<\/p><p>If you use Hostinger VPS, enter prompts into our AI assistant, Kodee, to help you navigate Screen.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn More About VPS<\/h4>\n                    <p><a href=\"\/ca\/tutorials\/how-to-install-ffmpeg\">How to Install FFmpeg on Linux<\/a><br>\n<a href=\"\/ca\/tutorials\/tmux-beginners-guide-and-cheat-sheet\/\">How to Use Tmux on Linux<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux Screen is a Terminal multiplexer that lets users create multiple virtual shell sessions in their system. It saves the current process in Terminal, keeping it running even after the user disconnects from the server. Also known as GNU Screen, this tool is especially useful when managing remote systems like a virtual private server (VPS) [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-install-and-use-linux-screen\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Use Linux Screen in %currentyear%","rank_math_description":"Linux Screen is a terminal multiplexer. It's used to improve your workflow. Check this article to learn how to install and basic usage examples.","rank_math_focus_keyword":"linux screen","footnotes":""},"categories":[22699],"tags":[],"class_list":["post-15504","post","type-post","status-publish","format-standard","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-utiliser-screen-linux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/instalar-usar-linux-screen","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/linux-screen","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/instalar-usar-linux-screen","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/instalar-usar-linux-screen","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/instalar-usar-linux-screen","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-and-use-linux-screen","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-and-use-linux-screen","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=15504"}],"version-history":[{"count":44,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15504\/revisions"}],"predecessor-version":[{"id":141492,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15504\/revisions\/141492"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=15504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=15504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=15504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}