Sysadmins generally work with the Linux terminal. You can get even more out of it by taking advantage of Linux Screen! Using this long running favorite tool is a must for anyone who wants to become an expert.
It might seem intimidating at first, but Linux screen is easy to learn while providing limitless possibilities. It’s efficient use system resources makes it an irreplaceable tool.
With this in mind, today we will teach you how to install and use Linux Screen to further increase the power and flexibility of the Linux Terminal.
What is Linux Screen?
A Linux Screen is a terminal application developed by the GNU project. Often official documentation calls it a GNU Screen. Screen has a clear goal – terminal multiplexing.
In other words, Screen divides a physical terminal into multiple virtual sessions and thus stops and summarizes the activity in them.
Screen works like this – if you work on a terminal session while using Screen, once we finish and turn off the computer it will save at that point. When the terminal is reaccessed, the terminal will return to the screen it was at right before shutting down.
Using Screen is a fundamental skill. It might not be packed with complex tech, but every Linux user should know how to use it.
How to install and use Linux Screen?
Screen is usually installed by default on all major Linux distributions. If your system doesn’t have it preinstalled, don’t worry! The installation is easy.
First, we need to connect to our server using SSH. To do this, run:
ssh your-user@server
On the other hand, if you’re running Linux on your own computer, just open the terminal from the main menu.
In the case of Debian, Ubuntu, Linux Mint and its derivatives, you can execute the following command:
sudo apt install screen

If you are using CentOS 7, you can install it as follows:
sudo yum install screen
Or if the user can’t run sudo commands, we need to run it as a root user.
yum install screen
At the end of the installation, we can check the current version of screen, using the following command line:
screen –version

This means we can use it now.
Using Linux Screen on any Linux Distribution
To run Linux screen, we just have to type it in our terminal session:
screen

After pressing the space key, you will see our terminal again. Do not worry, we have already started a new Screen session. To check it, just type exit and press enter.

So, we need to run the screen command again to start a new session.
screen
We can also start a session and give it a name by using the -S variable. For example:
screen -S session1
We recommend you give the session a descriptive name. With this, you will have no problem identifying it.
Screen uses commands to perform terminal multiplexing. The commands are easy to learn. They all follow a CTRL+* * structure, where * is a variable.

Working in a new session
Once we have started a new session it is necessary to learn how to use it. These are the main commands you’ll be using
| Commands | Description |
| CTRL+a c | Create a new window |
| CTRL+a ” | List all the windows created |
| CTRL+a a | With this command, you can delete a CTRL+a. Useful if you are wrong. |
| CTRL+a CTRL+d | Leave the session running. |
It is also possible to split the terminal screen. For example, using CTRL+a S splits the terminal horizontally.

To change to the next terminal, we press CTRL+a TAB. To close it, CTRL+a X.
The Power of Linux Screen
One of the great qualities of Screen is the ability to perform actions and leave them in the background so that when we return to them they’re still there. This is especially great for server administrators.
For this example, I will use htop. We can install it on Debian, Ubuntu, Linux Mint and derivatives with the following command:
sudo apt install htop
So, first run htop.

Next, we will press the keys CTRL+a and CTRL+d to save the execution of the terminal. Then, we will close all sessions by typing exit and pressing enter.

Now, we need to open a new terminal and run:
screen -ls

With this command, we will be able to show all “saved” sessions and reconnect to them. To do so run this command:
screen -r process_number
In this case it is 4305.

Wrapping Up
It is really important to learn how to install and use Linux Screen especially if you work with server administration. Here you learned how to do so, and how to start integrating it into your workflow. Wehope you found this Linux tutorial helpful!
If you want to learn more complex actions, we recommend referring to the official documentation. How will you use screen? Let us know in the comments!

Add Comment