Screen Command Cheat Sheet
Escape key
All screen commands are prefixed by an escape key, by default |
Getting in
| Start a new screen session with session name |
| List running sessions/screens |
| Attach to a running session |
| Attach to a running session with name |
| The "ultimate attach" Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one. If multiple sessions exist, uses the first one. |
Getting out
| Detach a running session |
| Detach |
| Detach and logout (quick exit) |
| Exit screen or exit all of the programs in screen |
| Force-exit screen (not recommended) |
Help
| See help Lists keybindings. The man page is the complete reference, but it's very long. |
Window Management
| Create new window |
| Change to last-visited active window (commonly used to flip-flop between two windows) |
| Change to window by number (only for windows 0 to 9) |
| Change to window by number or name |
| Change to next window in list |
| Change to previous window in list |
| See window list (allows you to select a window to change to) |
| Show window bar (if you don't have window bar) |
| Kill current window (not recommended) |
| Kill all windows (not recommended) |
| Rename current window |
Split screen
| Split display horizontally |
| Split display vertically or |
| Jump to next display region |
| Remove current region |
| Remove all regions but the current one |
Scripting
Send a command to a named session screen -S <name> -X <command> | |
Create a new window and run ping example.com screen -S <name> -X screen ping example.com | |
Stuff characters into the input buffer using bash to expand a newline character (from here) screen -S <name> [-p <page>] -X stuff $'quit\r' | |
A full example # run bash within screen screen -AmdS bash_shell bash # run top within that bash session screen -S bash_shell -p 0 -X stuff $'top\r' # ... some time later # stuff 'q' to tell top to quit screen -S bash_shell -X stuff 'q' # stuff 'exit\n' to exit bash session screen -S bash_shell -X stuff $'exit\r' |
Misc
| Redraw window |
| Enter copy mode or |
| Paste |
| Monitor window for activity |
| Monitor window for silence |
| Enter digraph (for producing non-ascii characters) |
| Lock (password protect) display |
| Enter screen command |
| Enable logging in the screen session |
Comments
Post a Comment