GNU Screen : Quick Reference : Cheatsheet


GNU Screen tool allows us to multiplex several virtual terminals inside an only physical one.

Among other features it provides session persistence.


Install Screen


$ sudo aptitude install screen # Install Screen on Debian and Ubuntu.



Run screen


$ screen # run screen application.
$ screen -ls # list all screen sessions.
$ screen -r # try to attach to a detached screen session.
$ screen -x # attach to an existing session even if it is not previously detached.
$ screen foo_command # run screen and execute "foo_command" in current window. If executed in an existing window, then it does not create a new screen session, but a new window in current session.



Commands inside screen


C-a c # create a new window.
C-a d # detach current session.
C-a n # move to next window.
C-a p # move to previous window.
C-a ? # show screen help.
C-a a # move back to latest used window.
C-a A # set window title.
C-a " # interactively select a window from a list.
C-a F # change window size to match current region.
C-a a # send "C-a" key combination to current window.
C-a x or C-a C-x # lock screen tool.
C-a k # kill current window.
C-a w # list all windows.
C-a 'digit' # e.g: C-a 1 moves to window number "1". Same happens with 2 to 9 and zero too.



Flow control


If flow control is enabled:

Command C-s (equals xoff) stops flow of bytes, and terminal pauses.

To enable flow of bytes again we need C-q command (equals xon).

C-a f # switch flow control state between these values: on / off / auto.


When flow control is enabled, to send C-s and C-q key combinations to current window:

C-a s # send "C-s" key combination to current window.
C-a q # send "C-q" key combination to current window.



Dealing with regions


C-a S # split current region horizontally.
C-a C-i # switch focus to next region.
C-a X # kill current region.
C-a Q # kill all regions but current one.



REFERENCE


$ man screen

http://www.gnu.org/software/screen