How To Use Linux Screen Command


Screen (GNU Screen) is a full-screen window manager that multiplexes a physical terminal. In simple words, it is a terminal multiplexer by which you can start a screen session and then run a program or start a process which requires an active terminal session inside a physical terminal.

Program or process running in screen session will continue to run even if it gets disconnected or closed accidentally. The same screen session can be resumed by reattaching to a session.

Install Linux Screen

If the Linux screen command is not already present on your system, you can install it with the following command.

Install Linux Screen on CentOS

yum install -y screen

Install Linux Screen on Fedora

dnf -y install screen

Install Linux Screen on Ubuntu and Debian

sudo apt install -y screen

Verify the installation by checking the Linux screen version.

screen -version


Screen version 4.01.00devel (GNU) 2-May-06

How To Use Linux Screen

Start New Linux Screen

To start a new screen session, just type screen command in the terminal.


Detach Linux Screen Session

As I said earlier, one of the main advantages of the screen is that you can detach the session any time, even in the middle of the work. Then, you can reattach to the same session and continue your work without losing anything you have worked.

You can detach from the current screen session at any time by pressing the following key combination.

ctrl+a d

You do not have to press key combinations all at once. First press ctrl+a and few seconds later press d. Follow the same for other combinations.

List Linux Screen Sessions

Before you reattach to your Linux screen session, you would need to know what are the Linux screen sessions are there on the system and their screen ID if you have more than one session.

List down the Linux screen sessions by typing the following command

screen -ls

Output: (Green one is the Screen ID)

There is a screen on:
        1297.pts-0.server       (Detached)
1 Socket in /var/run/screen/S-root.

Make a note of the screen ID as you would need it for reattaching to a Linux screen session.

Reattach to a Linux Screen Session

After you list down the number of Linux screen sessions on your system, you can use screen -r command with the screen ID you found with screen -ls to reattach to the screen.

screen -r 1297

Name a Linux Screen Session

Naming a screen session is useful when you have multiple screen sessions and it helps to locate the session ID for the correct session easily.

For example, you can name a session as download_iso for downloading some iso image with wget command.

screen -S download_iso
When you use a named session, you can reattach to the screen with the name screen -r download_iso instead of screen ID.

Nested Linux Screen Windows

When you start a new Linux screen session, it creates a single screen session for your work. You can create multiple session inside a screen session.

To create a new session inside a screen session, type:

ctrl+a c

Session number 0…X will be assigned to it depending upon the screen number available.

Screen 0:

Linux Screen Session 0
Linux Screen Session 0

Screen 1:

Linux Screen Session 1
Linux Screen Session 1

Screen 2:

Linux Screen Session 2
Linux Screen Session 2

Important Key Combinations

ctrl+a ”  – List all windows
ctrl+a – Switch to session number 0
ctrl+a – Go to next session
ctrl+a – Go to the previous session
ctrl+a – Split current region horizontally into two regions
ctrl+a l   – Split current region vertically into two regions
ctrl+a Q – Close all sessions except the current one
ctrl+a – Close the current session

Logging Linux Screen Sessions

Enabling logging feature will help us to record activities done while you are in the session.

To start logging of a session, press.

ctrl+a H


Enable Linux Screen Logging
Enable Linux Screen Logging

Alternately, you can enable the logging feature while starting a new screen session by adding -L parameter to the screen command.

screen -L

You can view the recorded data screenlog.1 in the home directory of the user.

Recorded Screen Session
Recorded Screen Session

Lock Linux Screen Session

You can lock your screen session by pressing the following keys.

ctrl+a x


Screen used by root  on server.

Use your Linux password to unlock it.

Linux Screen Parameters

Anytime you forgot the key mappings for a particular function ( Ex. Detach – ctrl+a d), you can use Ctrl+a and ? to see all parameters on screen to see Linux screen key mappings.

Linux Screen Key Bindings
Linux Screen Key Bindings

To quit the help screen, press Space-bar or Enter.


In this post, you have gone through how to use Linux Screen command. You can learn more about using and customizing Linux Screen at Screen User Manual page.

Further Reading

How To Use Linux Screen Command