What do you do if you lose your SSH connection to a server and you want to open the same session to continue the work your were doing? You use the command screen1 .

Screen is usually pre-installed in modern Linux distros, but if it’s not you can install it using sudo apt install screen.

Using screen

Start a session you don’t want to lose:

screen -S session_name

Now you have a session where you can work and come back if your connecton is lost.

Coming Back to Your Lost Session

Connect to your server and check the list of screen sessions available:

screen -ls

Connect to your session using its ID number that you can find next to the session name:

screen -r session_ID_number

Killing a Screen Session

while in the session press:

ctrl+a k