GNU Screen for Mere Mortals
A terminal is a fragile thing to hang work on. The connection drops, the laptop closes, the VPN blinks — and the shell that was halfway through a four-hour job dies with it. GNU Screen is the old, small, everywhere program that ends that bargain. It is a terminal multiplexer: it keeps virtual terminals — windows — alive on the machine, holding your running programs, while you come and go. You detach and the work runs on; you reattach, from the same terminal or another continent, and the scene is exactly as you left it.
This guide explains how that works,
takes your first session end to end,
and then builds the whole craft on it:
juggling windows and splits in one
terminal, reading and copying from the
scrollback, shaping Screen with a
.screenrc file, sharing a session
with a second pair of eyes, and the
daily pattern of living on remote
machines over SSH while your sessions
outlast every connection.
One rule is stated in chapter 1 and kept everywhere: a session is an unlocked shell — anyone who can attach to it can type in it as you. The lab obeyed the domestic version of that rule strictly: every session in this guide ran on one machine, under a throwaway account created for the purpose, and the only other "person" at the keyboard was a script.
The lab behind this guide ran the real
thing: GNU Screen 4.9.1, the Ubuntu
24.04 package, exercised as a dedicated
lab user on a small Linux sandbox.
Against it the lab detached sessions
holding a printing clock and collected
their output from outside while nobody
was attached; drove genuinely
interactive sessions through a
pseudo-terminal — windows created,
split, and detached by real Ctrl-A
keystrokes, not narration; copied text
out of the scrollback with copy-mode
keys and read the paste buffer back;
measured a .screenrc setting keeping
1503 printed lines where the system
default kept 1048; moved the command
prefix from Ctrl-A to Ctrl-T and
proved the old prefix dead; attached
two clients to one session at once and
watched each see the other's typing;
and started window logging with a
keypress and read the log file that
began at exactly that keypress.
What the lab could not do, it did not
fake. The sandbox had no SSH server, so
the SSH chapter teaches a pattern whose
Screen half is verified here and whose
transport half is standard SSH, and it
says so. Admitting a different user
to a session (multiuser mode) is
described from the manual, because the
lab's unpacked Screen does not
reproduce the file permissions that
guard that door on a stock install.
The vertical-split key is likewise from
the manual — a split is a redraw, and
a redraw is the one thing a text
transcript cannot flatten into proof.
criteria.md keeps the full ledger of
what was run and what was only read.
What this guide covers
- What GNU Screen is — the mental model: terminals that outlive their connections, and the one rule about unlocked shells
- The moving parts — the server and the client, sessions, windows, the command prefix, the socket, and who holds what when things break
- Installing GNU Screen — checking for it first, the package install, and the two configuration files
- Your first session — the complete round trip once, slowly: start, detach, prove it lives, reattach
- Detaching and reattaching —
-ls,-r,-d -r,-x, and ending a session on purpose - Windows and splits — several terminals in one session, and several on screen at once in regions
- Copy mode and scrollback —
walking the buffer, marking text,
pasting it elsewhere, and
hardcopy - Configuring Screen —
a
.screenrcworth having: scrollback, a status line, ready-made windows, a moved prefix - Sharing a session —
a second client with
-x, pair work, and the other-user route, with its rule - Sessions over SSH —
the remote-work pattern:
-dR, the dropped connection,$STY, nested sessions - Recipes — the build that survives the train, a real log of an overnight run, driving a session from a script, tidy-up day
- The neighbours —
tmux the heir, dtach and abduco the
minimalists, Byobu, and why
nohupis not the same job - Limits — reboots end everything, a dead server is a dead session, the scrollback is memory, one session one machine
- Troubleshooting — the vanished session, the dead listing, the prefix that does nothing, the configuration change that does nothing
- Glossary — the terms, collected in one place
What it doesn't cover
Running programs as boot-time services — that is a service manager's job, and chapter 13 says where Screen's part ends. Restoring sessions across a reboot, moving a live session between machines, and terminal emulators themselves (Screen lives inside one, it is not one). tmux gets a fair chapter as a neighbour, not a tutorial; this series has a guide of its own for that. And nothing here is a way to watch or enter another person's sessions: the socket permissions are the boundary, and the guide treats them as one.
How to use this guide
Read chapter 1 for the model and the
rule, and chapter 2 before the keys
start flying — knowing which part holds
what turns later surprises into named
problems. Chapter 4 is the whole craft
in five minutes; do it at a keyboard.
Chapters 5 to 8 are the daily tools, in
the order you will reach for them.
Chapter 9's rule comes before its
recipes for a reason. Chapter 10 is the
pattern most readers will live in;
chapter 11 is that pattern and its
friends, written as checklists. The
lab's transcripts live in
screen-lab/transcripts/; the program
that re-runs the whole lab is
screen-lab/run-lab.sh, its
pseudo-terminal driver is
screen-lab/drive.py, and its notes
are examples/lab-notes.txt. The
example configuration is
examples/screenrc.
Part of the series
This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.
Related guides:
License
The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.