GNU Screen Cheatsheet

3 min read·Matthieu

Quick reference for GNU Screen keyboard shortcuts, CLI flags, copy mode navigation, and region management.

Session Management

Action Command
Start named session screen -S name
List sessions screen -ls
Reattach to session screen -r name
Force-detach and reattach screen -D -r name
Detach remote, reattach here screen -d -r name
Multi-display attach screen -x name
Start detached session screen -dmS name
Remove dead sessions screen -wipe
Send command to session screen -S name -X quit
Enable logging from start screen -L -S name

Keyboard Shortcuts

All shortcuts start with the prefix Ctrl-a (default escape key).

Shortcut Action
Ctrl-a d Detach from session
Ctrl-a c Create new window
Ctrl-a n Next window
Ctrl-a p Previous window
Ctrl-a 0-9 Jump to window by number
Ctrl-a " List windows (interactive)
Ctrl-a A Rename current window
Ctrl-a k Kill current window
Ctrl-a ? Show all key bindings

Region (Split) Management

Shortcut Action
Ctrl-a S Split horizontally
Ctrl-a | Split vertically
Ctrl-a Tab Move to next region
Ctrl-a X Close current region
Ctrl-a Q Close all regions except current
Ctrl-a :resize +5 Grow region by 5 lines
Ctrl-a :resize -5 Shrink region by 5 lines

Region layouts are lost on detach. Recreate them manually after reattaching.

Copy Mode

Enter copy mode with Ctrl-a [ or Ctrl-a Esc. Paste with Ctrl-a ].

Key Action
Arrow keys / h/j/k/l Move cursor
Ctrl-u / Ctrl-d Scroll half page up / down
0 / $ Beginning / end of line
g / G Top / bottom of scrollback
/ / ? Search forward / backward
Space Set mark (start/end selection)
Enter Copy selection and exit
Esc Exit without copying

Increase the default 100-line scrollback buffer in .screenrc:

defscrollback 10000

Essential .screenrc

startup_message off
shell /bin/bash
defscrollback 10000
term screen-256color
vbell off
altscreen on
autodetach on
nonblock on
deflogin on
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%{g}][%=%{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%=%{g}][%{B}%Y-%m-%d %{W}%c%{g}]'

Troubleshooting Quick Fixes

Problem Fix
Session stuck as "Attached" screen -D -r name
Dead sessions in list screen -wipe
Terminal frozen (XOFF) Ctrl-a q
Garbled characters Add defutf8 on and term screen-256color to .screenrc
Enable window logging Ctrl-a H (logs to screenlog.N)

For the full tutorial, see How to Use GNU Screen on a Linux VPS.

Ready to try it yourself?

Get a Linux VPS ready in seconds.