Screen: Run processes in the background on a Linux server

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:35

The program "Screen" can run processes in background on a Linux server.

This starts an new background session with name "your-screen-name"

screen -S your-screen-name

To save the screen and return to the terminal, type Ctrl+A+D (Ctrl+A is the hint for screen that you want to do something and "D" then "d"etaches from the session without stopping it).

Restore your screen :

screen -d -r your-screen-name

List all available screen sessions:

screen -list

Type screen -list or -ls to identify the detached screen session.

$ screen -list 
    There are screens on: 
         20751.Melvin_Peter_V42  (Detached)  

Note: 20751.Melvin_Peter_V42 is your session id.

Quit a screen session: 

screen -X -S [session id you want to kill] quit

Or just type


if you are attached in your screen session.

Use ampersand

There is also the possibility to use the ampersand (&) character after your command, to run the process in background:


Afterwards you can jump with the "fg" and "bg" commands between foreground and background of the process.