How to install and use Screen on Linux

Screen is a terminal program for Linux which allows you to multiplex your terminal window and manage them simultaneously. it allows you to access multiple terminal sessions within a single terminal session. this tool is most useful when you are connected to a Linux system remotely like SSH sessions when you want to do multiple things and without Screen you need to do them one by one but using Screen you can do multiple things simultaneously. Screen also lets multiple remote systems connect to a specific screen session at once.

Install Screen on Linux

First, we are going to check if Screen is already installed on our system with the following command:

screen --version

If the output was something like below then you have Screen already installed otherwise you need to install it first:

Screen version 4.06.02 (GNU) 23-Oct-17

Install Screen on CentOS

The CentOS base repository does not provide Screen, so you need to add “EPEL” repository first. EPEL is one of the most popular and safe third-party repositories for RHEL Operating systems:

yum install epel-release

Now you can install Screen easily using yum:

yum install screen

Install Screen on Debian/Ubuntu

Execute the following commands to install Screen on your Debian or Ubuntu machine:

apt update
apt install screen

Start Screen

To start a Screen session simply type “screen” and hit enter:

screen

This will create a screen session and start a shell in that window, to start let’s see the available commands, you can see the manual with “Ctrl+a ?” shortkey:

Ctrl+a ?

Create Named sessions

Named sessions are very useful when you are going to run multiple screen sessions, it helps you navigate through your screen sessions easily using custom names for each one of them, You can create a Screen session with a custom name with the following command:

screen -S custom_name

To create a new screen session when you are already inside one you can use “Ctrl+a c” shortkey:

Ctrl+a c

it will create a new screen session and the first available number from range 0 to 9 will be assigned to it.

 Most common Screen shortkeys

Below are some of the most common shortkeys that will be handy when you are working with Screen:


Ctrl+a c >> Will create a new Screen window

Ctrl+a " >> List all windows

Ctrl+a 0 >> Switch to window number 0 (or any other number)

Ctrl+a A >> Rename the current window

Ctrl+a S >> Split the current window horizontally

Ctrl+a l >> Split the current window vertically

Ctrl+a >> Switch between the current and previous region

Ctrl+a Q >> Close all regions but the current one

Ctrl+a X >> Close the current region

Detach from Screen session

You can detach from a Secreen session at any time easily with:

Ctrl+a d

The program running that session will continue running in the background after you detach from it.

Reattach to Screen session

If you want to resume your screen session, you can use the following command:

screen -r

If you have multiple Screen sessions running on your system, you will need to add the screen session ID after the “-r” argument like below:

screen -r 9

To see your sessions list to find the ID you can type:

screen -ls

You can find more information about the GNU Screen project on its official website

Leave a Reply

Your email address will not be published. Required fields are marked *