A Reference Of Linux Screen Commands Because I Keep Forgetting Them
screen is a command that allows you to:
- Use multiple shell windows from a single SSH session.
- Keep a shell active even through network disruptions.
- Disconnect and re-connect to a shell sessions from multiple locations.
- Run a long running process without maintaining an active shell session.
Starting Linux Screen
Screen is started from the command line just like any other command:
[root@okcomputer ~]# screen
You are now inside of a window within screen. This functions just like a normal shell except for a few special characters.
Screen uses the command
Ctrl-a” as a signal to send commands to screen
instead of the shell.
Ctrl-a ? gives you the key bindings page.
Detaching From Screen
You can detach from the window using
Reattach to Screen
If your connection drops or you have detached from a screen, you can re-attach by just running:
[root@okcomputer ~]# screen -r
To stop the screen session, enter
exit into the shell or use
To run a single command in screen and detach:
[root@okcomputer ~]# screen -dm ./myscript.sh
To run multiple commands:
[root@okcomputer ~]# screen -dm bash -c "sleep 10; myscript.sh"
To list all sessions:
[root@okcomputer ~]# screen -list
Please note that when a program terminates, screen (per default) kills the window that contained it.
Want to get an email every time I post something? Enter your email address below.I promise I won't spam you.