What is Screen?
We often face a situation on a remote machine where we perform a task on Linux, and those tasks are very long-running. Therefore, many problems are generated, such as the session of SSH is terminated, suddenly our connection drops, our all work is corrupted or lost.
This screen is the tool we use for resuming sessions and continuing tasks. The screen helps physical console between typically interactive shells (several processes). A single terminal window manager screen allows the user to open several separate screen sessions.
How to Use Screen in Linux
GNU Screen or Screen is a terminal multiplexer. The screen allows us to resume or start a session, and then inside that session, we can open virtual terminals (any number of windows). Our running processes will continue to screen when we get disconnected for any reason or even if the window is not visible.
Install Screen in Different Operating Systems in Linux
As we know, there are different operating systems in Linux. So, there are different commands available to install the screen on the particular operating system of Linux.
Install GNU Screen in Linux
We can check that the screen package is pre-installed in our Linux system by following the command, because nowadays on most distros, the screen package comes pre-installed.
If we have a pre-installed screen package, then output shows the particular version of that package. Otherwise, if it is not, we can easily install the screen package with the help of the package manager of our distro.
Install Linux Screen on Linux
We can install the screen on Debian, Ubuntu, and Mint in the Linux system using the following command.
The following command can be installed by installing the screen on Fedora/CentOS/RHEL/AlmaLinux/Rocky Linux in Linux.
Install the screen on Gentoo Linux by using the following command.
Install the screen on Manjaro by using the following command.
Install the screen on Arch Linux by using the following command.
Install the screen on OpenSUSE by using the following command.
Starting the Linux Screen
Once the screen package is installed in Linux, it is easy to start it. You just have to run the below command:
The above command creates a new window by starting a shell in that window and opening a screen session.
Now we get a list of commands in the screen session opened above. The following command shows us the list of commands.
How to Use Screen
In Linux, when we start a screen session, choose between two windows. One screen session may contain multiple windows.
We can do all our work in the normal command-line environment. As we already know, a screen is an application, so it also has specific parameters or commands.
To check all the parameters on the screen, we can type the following command.
The above command is the shortcut key of the help screen. We can also use another command which is as follows.
In the output, we can see all the parameters or commands on the screen.
To exit the help screen, we can press the “spacebar” or “Enter.” Note that all shortcuts “Ctrl+a” are done without quotes in the screen session.
For managing the Linux screen windows, some of the most common shortcut keys are as follows
|Ctrl+a c||New Window creates with a shell|
|Ctrl+a “||Shows all list of windows|
|Ctrl+a 0||By number (select window 0)|
|Ctrl+a A||Give the window a new name.|
|Ctrl+a S||Horizontally split the current region into two regions.|
|Ctrl+a |||Vertically split the current region into two regions.|
|Ctrl+a tab||Switch the input target to the next region.|
|Ctrl+a Ctrl+a||We can toggle between the previous and current windows|
|Ctrl+a Q||Close all regions but this one.f|
|Ctrl+a X||Shut down the current region|
Starting the Named Session
When we run multiple screen sessions in our Linux system, then named sessions are useful. We can easily create a session that identifies the session by that particular name. We can create a named session by running the screen command with the command given below.
Choosing a descriptive session name turns out to be a good idea.
Detaching Linux Screen Session
Detaching the screen is one of the best advantages. We write the following command, and by using that command, we can easily exit the screen session in Linux.
So, with the help of the above command, the screen session exits, but still, the running program continues to work.
Resume the Screen Session
Using the following command, we can again resume or reattach the screen session without losing anything we have done in the Screen session.
We can find the current session ID by listing the running screen sessions.
Running screen sessions and detached screen sessions are shown in the output, and we easily restore the particular version. We can use the following command to display the screen session running in the background and the currently opened screen.
Just suppose the output will be :
Now we want to restore the 10835-screen session. So, we have to write the following command.
Linux Screen Customization
If the file is present in our screen session and the session is started, the screen reads the configuration parameter of the screen from the following command.
According to our priorities, we can modify the default screen by using the below command.
Check Manual Page
By using the following command, we can check the manual page on the Linux screen.
In this article, we learned how to install and use Gnu Screen in Different Operating systems of Linux. We can easily create multiple screen windows in a single screen session, navigate between windows, resume and detach screen sessions and personalize our screen terminal with the help of specific commands or keys. We have tried to put all the information related to the user screen in Linux, and we hope that article is beneficial for you. We also make sure to grab all information in this single article. That is all you need to know.