How to Screen — keep running a task using a remote server via ssh

Usually, when facing a situation where we need to perform a long-running task on a remote machine/server. To do this, we usually use ssh to make a connection to the remote machine and write/execute some lines of code. But, our ssh session won’t be alive forever, it has a limit of time terminating and (in too many cases) losing all information or processing performed.

For these cases, today I present a solution. A very helpful tool called screen allows us to resume sessions. So, Screen is a tool developed by GNU is defined as a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session.

Install Linux GNU Screen
The screen package is part of the general distribution in Linux systems.

sudo apt-get install screen

Then, you can verify the version:

screen --version

Startin with screen
You can create a session by just by typing:

screen -S session_name

Once you create a session, you will be attached to it. So, if you want to know in which session are you, just type:

screen -ls
You can verify your current session by the word attached

Attach Linux Screen Session
You can attach your session just by typing the name or the id:

screen -r exmaple
screen -r 2444391

Detach from Linux Screen Session
You can detach your current session at any time by typing:

Some useful commands for Linux Screen Session

Some commands, taken from here.

Some advances comments
You can personalize your session by modifying the file and if the file is present.

I hope you enjoyed reading this. :D :D

Computer Scientist at(@UNIoficial) and Cat lover ❤. Visit

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store