Screen for Linux

2 min read

GNU Screen

is an application that enables running multiple virtual terminals within sessions. Once a session is created, you can disconnect from it and later reconnect, even from a different host with an SSH client installed. Processes started in Screen continue to run even when a user disconnects from the session or the host. This is another reason (in addition to the convenience of working in the command line by switching between windows) why Screen is used. If your internet connection is unreliable, or you need to start a process in the office and stop it at home, using Screen (or similar applications like Tmux) can solve these issues.

INSTALLING THE SCREEN UTILITY

The installation of the program differs on various distributions due to package management programs and their commands. To install Screen on Ubuntu, Linux Mint, Deepin, and other Debian-based systems, use the apt command:

sudo apt install screen

In Manjaro, Antergos, and other Arch-like OSes, Screen can be found in AUR, so you should use an appropriate package management program like aurman:

aurman -S screen

For installing Screen on Red Hat-based systems (e.g., Fedora and CentOS), use the dnf utility:

dnf install screen

Linux Screen Commands After installation, you can start the Screen program using the screen command. This will create a session with a name that includes the session's own process identifier (PID) and part of the hostname. To assign a name to the session, you need to use the -S flag:

screen -S namescreen

To manage the session after entering it, you will use key combinations. The introductory key combination for Screen is ctrl + a. After that, you input a character that is defined for a specific action. For example, to disconnect from a session, you need to input the d character, like this:

ctrl + a d

To create a new window, you use the c character:

ctrl + a c

To switch to the next window:

ctrl + a n

To switch to the previous window:

ctrl + a p

To select a specific window:

ctrl + a " (or ctrl + a 1, where 1 is the window number)

To close the current window:

ctrl + a k

When you close the last window, the session itself is destroyed. To destroy all windows and exit Screen:

ctrl + a ctrl

To split a window horizontally:

ctrl + a S

You can find a complete list of key combinations in the documentation using the command:

man screen

To list available sessions, you can use the command:

screen -ls

To connect to a specific session (e.g., namescreen):

screen -x namescreen
Didn’t find the answer?Contact support — we’ll help you sort it out.
Open a ticket →