Sessions
screen -S <name>
New named session
Without -S the session is named
<pid>.<tty>.<host>.
screen -r <name>
Reattach to a session
With only one detached session, plain screen -r is enough.
prefix
d
Detach from session
Programs inside keep running; reattach any time.
screen -R <name>
Reattach, or create if missing
Handy for aliases; -RR picks the first detached session.
screen -x <name>
Attach to an already attached session
Shares the session between two terminals (pairing).
screen -d -r <name>
Detach it elsewhere, reattach here
Use when it says Attached; -D -r also logs out the remote.
screen -dmS <name> <cmd>
Start a command detached
prefix
\
Kill all windows and quit
Asks for confirmation.
screen -wipe
Remove dead sessions
screen -S <name> -X quit
Kill a session from outside
prefix
D
D
Power detach and log out
Windows
prefix
n
/
p
Next / previous window
Space and Backspace do the same.
prefix
0-9
Jump to window number
prefix
"
Choose window from list
Move with arrows, Enter selects.
prefix
Ctrl+a
Toggle to the last used window
prefix
w
Show window list in status line
prefix
k
Kill window
Asks for confirmation (y/n).
prefix
'
Select window by number or name
Needed for windows 10 and above.
prefix
i
Show info about this window
prefix
N
Show window number and title
prefix
C
Clear the screen
prefix
l
Redraw window
Fixes a garbled display.
screen -t <title> <cmd>
Open a window running a command
Use as a command line inside (C-a :) or a .screenrc line.
number <n>
Renumber current window
Copy Mode
prefix
[
Enter copy / scroll mode
Scroll with arrows or PageUp/PageDown. Esc also enters it.
Space
Set start, then end of selection
Press once to mark, move, press again to copy.
Esc
Leave copy mode
Any unbound key leaves it.
prefix
]
Paste last copied text
Pastes screen's own buffer, not the system clipboard.
/
/
?
Search forward / backward
n
/
N
Next / previous match
Ctrl+u
/
Ctrl+d
Half page up / down
g
/
G
Jump to top / bottom
0
/
$
Start / end of line
w
/
b
Next / previous word
c
/
C
Set left / right column of block
For rectangular selections.
prefix
>
/
<
Write / read the paste buffer file
Default file is /tmp/screen-exchange.
prefix
h
Save screen to hardcopy.<n>
defscrollback 10000
Longer scrollback in .screenrc
Default is 100 lines; applies to windows created afterwards.
Copy mode movement
| Move |
Key |
| Line / column |
h j k l |
| Half page |
Ctrl+u / Ctrl+d |
| Full page |
Ctrl+b / Ctrl+f |
| Screen top / bottom |
H / L |