Screen is a very powerful tool to keep a process running in the background while retaining the ability to log out and log back in anytime to check on the output.
Annoyingly I keep forgetting the commands to use screen
effectively so here’s a quick reference guide of commands and shortcuts for myself and maybe others.
Commands
To start a screen session:
$ screen -S <command>
To list existing screen sessions:
$ screen -ls
To reconnect to a screen session:
$ screen <session_name>
To reconnect to a still attached screen session:
$ screen -rd <session_name>
Shortcuts
To detach a screen session: ctrl + a + d
To open a new screen session while inside screen: ctrl + a + c
To switch back to the previous screen session: ctrl + a + p
To switch to the next screen session: ctrl + a + n