This is an old revision of the document!
With “screen” you can run a shell in background (for e. g. running scripts), but when shell terminates, screen still runs!
You can start screen by executing
screen
Optional: Start logging (each command executed in screen will be written to a file such as “screenlog.0” in the home directory of the screen executing user):
ctrl + a H
Detach from running screen:
ctrl + ad
List all screen-sessions:
screen -ls
If there´s just one screen running attach:
screen -r
If there´s are several screen running and you want to attach to:
1. execute:
screen -ls
Example output:
root@demo-host:~# screen -ls There are screens on: 15893.pts-0.demo-host (05/27/2016 03:46:27 PM) (Detached) 1864.pts-0.demo-host (05/27/2016 12:27:05 PM) (Detached) 2 Sockets in /var/run/screen/S-root.
2. execute:
screen -r 1864.pts-0.demo-host
Terminate all screen-sessions:
screen -X quit
Terminate single screen-session:
screen -X -S ID quit
Example:
screen -X -S 1864.pts-0.demo-host quit
Attach to an already attached session (e. g. after network disconnect):
screen -rd screen -r -d 30608