VPS

How to Install and Use Linux Screen?

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

Installing Screen on Ubuntu Linux

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

Checking the Version of Linux Screen on ubuntu

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

Running Linux screen on ubuntu

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.

Exiting Linux Screen on Ubuntu

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.

Linux Screen command list on Ubuntu

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

CommandsDescription
CTRL+a cCreate a new window
CTRL+a  ”List all the windows created
CTRL+a aWith this command, you can delete a CTRL+a. Useful if you are wrong.
CTRL+a CTRL+dLeave the session running.

It is also possible to split the terminal screen. For example, using CTRL+a S splits the terminal horizontally.

Splitting the Linux terminal using Screen on Ubuntu

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.

Running htop on Ubuntu

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.

Saving a Linux Screen session

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

screen -ls

Listing all Screen sessions on Ubuntu

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.

Resuming a Linux Screen session

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!

About the author

Edward S.

Edward is Hostinger's copywriter. He's an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward's goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in VPS
Linux Rsync (Remote Synchronization) Command
Close