How to use Linux Screen command

Decrypt3r
2 min readSep 10, 2022

In this article I’ve tried to explain the use as well as various options which you can use in screen. Screen is used in linux environment to run scripts or commands in the background. If you run screen and your login session get interrupted then it will keep the process running in the background and you can recover your work back.

How to use Linux Screen command
How to use Linux Screen command

To check which screen version you are currently using then enter the following command:

screen — version

To list the all screen sessions try to use the below command:

screen -ls

To start a new screen session, type the following command in terminal:

screen

If you want to exit or detach current screen session then use the following shortcut. This won’t kill the screen session it will only help you to exit from the screen and keep the process running in background.

Ctrl+a d

To create a new screen and give it a name use -S option and specify the name for screen:

screen -S any_name

If you detached a screen and want to reattach it then you have to list the screen sessions to check it’s name or session id which you can get by using -ls option as I explained before. And to reattach use one of the option as follows:

screen -r screen_name

OR

screen -r session_id

To create new window with shell you can use:

Ctrl+a c

After using the above option it will create a new window shell, you can create multiple windows using this shortcut and to list all the windows use:

Ctrl+a ”

To switch the window to a particular number, use following option. To go to the particular window just replace 0 (zero) with window number.

Ctrl+a 0

If you want to rename the current window then type:

Ctrl+a A

You can also split screen sessions. To split screen session horizontally then use shortcut:

Ctrl+a S

And to split screen session vertically, you can use | (pipe operator):

Ctrl+a |

If you split a screen session and want to switch the focus then follow below shortcut:

Ctrl+a tab

To learn more about screen or to get help about using a screen you can use following option:

Ctrl+a ?

And finally if you want to kill the screen session in which currently you are in then follow the below shortcut:

Ctrl+a k

I hope you like this article, for more articles you can follow my profile.

--

--