screen -S <name>
screen -ls
screen -x
screen -r <name>
screen -dRR (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.)
All screen commands are prefixed by an escape key, by default C-a
(that's Control-a, sometimes written ^a). To send a literal C-a
to the programs in screen, use C-a a. This is useful when working with screen within screen. For example C-a a n will move screen to a new window on the screen within screen.
C-a c
C-a C-a (commonly used to flip-flop between two windows)
C-a <number> (only for windows 0 to 9)
C-a ' <number or title>
C-a n or C-a <space>
C-a p or C-a <backspace>
C-a " (allows you to select a window to change to)
C-a w (if you don't have window bar)
C-a k (not recommended)
C-a \ (not recommended)
C-a A
To any session name,
screen -S <name> -X <command>
screen -S <name> -X screen ping example.com
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'
In copy mode, one can navigate the scrollback buffer in various ways: