How to Use Linux Screen Command With Examples

Use Linux Screen Command With Examples

The screen command in Linux is used creating terminal multiplexing. By using screen you can run any number of the terminal-based applications. Screen command can enable you to resume your work where the last time you exited the application. Users can open multiple instances of terminal inside one single terminal by using screen command very easily. If you exit the terminal then the process running in the terminal will not break it will be continued in the background so you can resume the session where you left. In this tutorial, you are going to learn How to Use Linux Screen Command With Examples.

Installing Linux Screen

First, confirm whether the screen command is installed or not on your system run following command:

screen --version

You can install a Linux screen using the following command in different Linux distros.

To install screen command in Ubuntu, Debian or any Debian based distro run following command:

sudo apt install screen

To install screen command in CentOS, RHEL run following command:

sudo yum install screen

For Fedora you can type the following command:

sudo dnf install screen

Using Linux Screen

You can start a new screen session by typing following command in terminal:


The output should look like the following:


Now to get the list of available commands by typing Ctrl+a ? in the current terminal.

Create New Session With Name

You create a new session with a specific name by using screen command with -S option:

screen -S NAME_OF_THE_SESSION/pre>

You can replace NAME_OF_THE_SESSION with the name you want to give to a new session.

Detach From Screen Session

You have created a new session you can also detach from the session. To detach from the session enter the following keys:

Ctrl+a d

The output should look like:


Re-Attach to a Linux Screen Session

You can re-attach to a previous screen session by using -r option with screen command.
To re-attach to a new session run below Linux screen command:

screen -r

If you have created multiple screen sessions then it will list you all the sessions available, then you should choose one of them and should run the following command:


screen -r 7582

After running above command you will be attached to a session with ID 7582.

List All Available Sessions Using Screen Command

You can also list all available sessions using -ls option with Linux screen command:

screen -ls

The output should look like:

There are screens on:
        7582.second_session     (Detached)
        7412.new_session        (Detached)
        7105.pts-1.localhost    (Detached)
3 Sockets in /run/screen/S-linux4one.



You have successfully learned How to Use Linux Screen Command With Examples. If you have any of the queries regarding this then please don’t forget to comment below.