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.

# Without screen: the job belongs to the SSH session's terminal laptop ──ssh──► sshd ──► bash ──► long-running job (connection drops → SIGHUP → bash and the job exit) # With screen: the job belongs to screen's own terminal laptop ──ssh──► sshd ──► bash ──► screen client │ (connection drops → only the client dies) screen server ──► bash ──► long-running job (keeps running, waiting for you to reattach)

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).
The programs don't know
As the GNU Screen documentation puts it, applications running inside screen don't even know the terminal has detached. No special support is needed: any command-line program works.

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 Screentmux
Age19872007
Prefix keyCtrl-aCtrl-b
LicenceGPLISC
StrengthsVery widely available, including on old systems; serial-console supportMore 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

# Is it already installed? screen -v # Debian / Ubuntu sudo apt install screen # Fedora (and RHEL-family systems, via EPEL where needed) sudo dnf install screen # Arch Linux sudo pacman -S screen
Not everywhere by default
Many minimal server images don't include screen, and Red Hat Enterprise Linux 8 dropped it from its main repositories in favour of tmux. On those systems it can usually be installed from EPEL, or you can use tmux instead — the concepts in this course still apply.

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

Exercise 1

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 solution
Exercise 2

On 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.

📄 View solution
Exercise 3

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 solution

Chapter 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 -v checks the version; install with apt, dnf (EPEL on RHEL-family), or pacman
  • Shell job control (&, Ctrl-Z, jobs, nohup, disown) is the other half of this course