Why Screen?
GNU Screen & Linux Job Control
Chapter 1 · Why Screen? Terminal Multiplexers & Persistent Sessions
You SSH into a server, start a backup, a large file copy, or a database import that will take an hour — and then your Wi-Fi drops, your laptop sleeps, or you simply need to go home. When you reconnect, the job is gone. This course is about stopping that from happening, and about understanding exactly how Linux manages the jobs you start.
Why Jobs Die When the Connection Drops
Every program you start from an SSH session is attached to a terminal — strictly, a
pseudo-terminal that sshd creates for your login. Your shell, and every job it starts,
reads from and writes to that terminal. When the connection breaks, the terminal "hangs up." The system then
sends the SIGHUP ("hang-up") signal to the shell, and the shell passes it on to its jobs. The
default reaction to SIGHUP is to exit, so your hour-long import stops wherever it was.
What a Terminal Multiplexer Does
GNU Screen is a terminal multiplexer. It runs a background server process that owns its own pseudo-terminals, and your shells and jobs run inside those instead of inside the SSH session's terminal. What you see is just a client connected to that server. Disconnect, and only the client disappears; the server, and everything running in it, carries on. This gives you three things:
- Persistence — detach from a session and reattach later, even from a different computer (Chapter 2).
- Multiplexing — many shells, called windows, inside one session, and split views of several at once (Chapter 4).
- Sharing and logging — two people can attach to the same session, and a window's output can be logged to a file (Chapter 9).
A Short History, and Screen vs. tmux
Screen was designed by Oliver Laumann and Carsten Bormann at the Technical University of Berlin and first published in 1987. It is now part of the GNU Project and still actively maintained, with a 5.x release line. Its best-known alternative, tmux, first appeared in 2007 and has a similar feature set.
| GNU Screen | tmux | |
|---|---|---|
| Age | 1987 | 2007 |
| Prefix key | Ctrl-a | Ctrl-b |
| Licence | GPL | ISC |
| Strengths | Very widely available, including on old systems; serial-console support | More modern design, easier scripting and configuration |
The ideas are the same in both — sessions, detaching, windows, panes — so what you learn here carries over. This course uses screen because it is the one you are most likely to find already installed on an unfamiliar server.
Installing and Checking Screen
What About Job Control?
Screen is one answer to the "my job died" problem, but not the only one. The shell itself has job
control: running commands in the background with &, pausing them with
Ctrl-Z, listing them with jobs, and protecting them from SIGHUP with
nohup and disown. Chapters 5–7 cover these, and Chapter 8 combines both
— including the common situation of wishing you had started a job inside screen after it is
already running.
Hands-On Exercises
In your own words, explain why a long-running command started directly in an SSH session stops when the connection drops, and why the same command started inside screen keeps running.
📄 View solutionOn a Linux machine (a virtual machine or WSL is fine), check whether screen is installed, install it if not, and report its version. Then run ps -o pid,tty,comm both outside and inside a plain screen session and note what changes in the TTY column.
For each situation, decide whether screen is a good fit and explain why: (a) a two-hour database import over SSH; (b) a web server that should start automatically at boot; (c) watching a log file in one window while editing a config file in another.
📄 View solutionChapter 1 Quick Reference
- Jobs started in an SSH session belong to its pseudo-terminal; a dropped connection sends SIGHUP, which stops them by default
- GNU Screen is a terminal multiplexer: a background server owns the terminals your jobs run in, so they survive disconnection
- It provides persistence (detach/reattach), multiple windows and split regions, and session sharing and logging
- Designed by Oliver Laumann and Carsten Bormann, first published in 1987; tmux (2007) is the main alternative
screen -vchecks the version; install withapt,dnf(EPEL on RHEL-family), orpacman- Shell job control (
&,Ctrl-Z,jobs,nohup,disown) is the other half of this course