Screen for Linux
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 screenIn 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 screenFor installing Screen on Red Hat-based systems (e.g., Fedora and CentOS), use the dnf utility:
dnf install screenLinux 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 namescreenTo 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 dTo create a new window, you use the c character:
ctrl + a cTo switch to the next window:
ctrl + a nTo switch to the previous window:
ctrl + a pTo select a specific window:
ctrl + a " (or ctrl + a 1, where 1 is the window number)To close the current window:
ctrl + a kWhen you close the last window, the session itself is destroyed. To destroy all windows and exit Screen:
ctrl + a ctrlTo split a window horizontally:
ctrl + a SYou can find a complete list of key combinations in the documentation using the command:
man screenTo list available sessions, you can use the command:
screen -lsTo connect to a specific session (e.g., namescreen):
screen -x namescreen