Linux Screen Command

Linux Screen Command
Linux Screen Command Examples

screen command LinuxWe’ll show you, how to use the Linux screen command. Linux Screen Command is a very useful command that offers the ability to use multiple shell windows (sessions) from a single SSH session. When the session is detached or there is a network disruption, the process that is started in a screen session will still run and you can re-attach to the screen session at any time. Linux Screen Command also comes in handy if you want to run a long process persistently or connect to shell sessions from multiple locations. In this article, we will show you the basics of installing and using screen command on Linux.

1. Installing Linux Screen Command

The screen comes preinstalled on some of the popular distributions. You can check if it is installed on your server using the following command

screen -v
Screen Command Example in Linux

If you do not have a screen to the VPS, you can easily install it using the package manager provided by the OS.

 2. Install Linux Screen Command – CentOS/RedHat/Fedora

yum -y install screen
  • Ubuntu/Debian
apt-get -y install screen

3. How to start a Linux Screen Command session

You can start screen by typing ‘screen’ at the command prompt and a new screen session will be started which looks the same as the command prompt


It is a good practice to start screen sessions with descriptive names so you can easily remember which process is running in the session. To create a new session with a session name run the following command

screen -S name

and replace ‘name’ with a meaningful name for your session.

4. Detach from Linux Screen Command Session

To detach from the current screen session you can press ‘Ctrl-A‘ and ‘d‘ on your keyboard. All screen sessions will still be active and you can re-attach to them at any time later.

5. Reattach to Linux Screen Command

If you have detached from a session or your connection is interrupted for some reason, you can easily re-attach by executing the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

screen -r

If you have multiple screen sessions you can list them with ‘ls’

screen -ls

There are screens on:
7880.session    (Detached)
7934.session2   (Detached)
7907.session1   (Detached)
3 Sockets in /var/run/screen/S-root.
linux screen command list
linux screen command list

In our example, we have three active screen sessions. So, if you want to restore the session ‘session2’ you can execute

screen -r 7934

or you can use the screen name

screen -r -S session2

6. Terminate Linux Screen Command Session

There are several ways to terminate the screen session. You can do it by pressing ‘Ctrl‘ + ‘d‘ on your keyboard or use the ‘exit’ command line command.

To see all the useful features of the screen command you can check the screen’s man page.

man screen

screen - screen manager with VT100/ANSI terminal emulation

screen [ -options ] [ cmd [ args ] ]
screen -r [[pid.]tty[.host]]
screen -r sessionowner/[[pid.]tty[.host]]

screen command in LinuxWith the completion of this tutorial, you have successfully learned how to use the Linux Screen Command. If you are one of our managed Linux hosting customers, you don’t have to use or learn the screen command in Linux, simply ask our system administrators to help you with any aspect of managing your Linux server. They are available 24/7 and will take care of your request immediately.

PS. If you liked this post on how to use the Linux Screen Command, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comment section. Thanks.

1 thought on “Linux Screen Command”

Leave a Comment