raw Software
RAW Software Terminal GNU Screen

GNU Screen Cheat Sheet

Robert Eisele

GNU Screen Cheat Sheet: start, name, detach, reattach, and navigate terminal sessions that keep running when your connection closes. Quick shortcuts cover windows, scrollback, splits, monitoring, logging, and safe session cleanup.

Start and Find Sessions

Start Screen in the current terminal

screen

Start a session with a memorable name

screen -S build

Start a named session in the background

screen -dmS build

List sessions and see whether each is attached or detached

screen -ls

Reattach to a detached named session

screen -r build

Session names distinguish concurrent jobs. If several sessions match, use the identifier printed by screen -ls.

Detach and Reattach

Detach from the current terminal; windows and programs keep running

Ctrl-a d

Detach this terminal from a session and attach here

screen -d -r build

Caution: -d -r disconnects the session from its other attached terminal. It does not stop the programs.

Attach another display to an already attached session

screen -x build

Multi-display mode shares the same session and keyboard input. Use it only when shared control is intended.

Windows and Processes

Create a shell in a new window

Ctrl-a c

Move to the next or previous window

Ctrl-a n
Ctrl-a p

Choose a window from the interactive list

Ctrl-a "

Rename the current window

Ctrl-a A

End the foreground shell or command

exit

Destroy the current window and its process

Ctrl-a k

exit ends the foreground shell; if it is the last window, Screen exits too. Ctrl-a k destroys the window and its process. Ctrl-a \ terminates all windows in the session.

Scrollback and Copy

Enter copy mode to browse the current window's scrollback

Ctrl-a [

Use the arrow keys or Page Up/Down to move. Press Space to set a mark, move to the other end, then press Space again to copy. Copy mode closes after the second mark.

Paste the copied text into the current window

Ctrl-a ]

Show the current window's information

Ctrl-a i

Increase scrollback for new windows in ~/.screenrc

defscrollback 10000

Split Regions

Split the current display horizontally

Ctrl-a S

A new blank region appears. Select a window for it with Ctrl-a c or Ctrl-a "; splitting alone does not create another process.

Move input focus to the next region

Ctrl-a Tab

Remove the focused region

Ctrl-a X

Keep the focused region and remove the others

Ctrl-a Q

Logging and Activity

Toggle logging for the current window to screenlog.n

Ctrl-a H

Save a hardcopy of the current visible window to hardcopy.n

Ctrl-a h

Alert when the current window produces output

Ctrl-a M

Monitor the current window for inactivity

Ctrl-a _

Logging caution: Screen logs terminal output to a file in the window's directory and appends to an existing log. Logs may contain secrets, commands, or private output; turn logging off when finished and protect the file.

Configuration and Cleanup

Send a literal Ctrl-a to the running program

Ctrl-a a

Show Screen's built-in key reference

Ctrl-a ?

Start a fresh session if the shell is already inside Screen

screen -mS nested

Remove only dead sessions from the session list

screen -wipe

Terminate a named session and every process in its windows

screen -S build -X quit

Caution: -X quit is destructive. Check the target with screen -ls first. It terminates the whole session, not just the current window.

The default command prefix is Ctrl-a. GNU Screen's official manual documents additional commands, configuration and key bindings.