Skip to content

What GNU Screen Is

You are logged into a machine over SSH — the standard way to get a command line on a computer that is somewhere else. You start a long job: a big compile, a download, a backup. Then the connection drops. A laptop lid closes, a train enters a tunnel, a router blinks. When you log back in, your job is gone — killed the moment its terminal vanished, mid-sentence.

GNU Screen is the program that makes that not happen. Screen is a terminal multiplexer: a program that sits between you and your shell and gives one connection many virtual terminals, called windows. The important trick is not the many windows. It is that Screen keeps those terminals alive on the machine, holding your running programs, after you disconnect. You detach — step away, leaving everything running — and later reattach from the same connection or a different one, and the screen is exactly as you left it, down to the cursor.

The programs inside never knew you were gone. From their point of view, their terminal sat open the whole time, patiently waiting.

Why anyone would do this

Four honest reasons account for nearly every use:

  • Surviving dropped connections. The founding reason. A long job on a remote machine should not live or die by the health of your Wi-Fi. Start it inside Screen, detach, and the job belongs to the machine, not to your connection.
  • One connection, many shells. One SSH login, and inside it a window for the editor, one for the logs, one for the shell where you test things — no pile of separate logins to the same machine, each forgetting the other's context.
  • Coming back to a scene. Detach on Friday with three windows arranged around a problem. Reattach on Monday and the scene is intact: same windows, same scrollback, same half-typed command. Screen is a bookmark for a whole working state, not just a command.
  • Letting someone watch. A second person can attach to the same session and see the same terminal, live — the pair-programming and remote-teaching chapter of this guide (chapter 9) is built on it.

The one rule, stated early

A Screen session is an unlocked shell. Anyone who can attach to it can read everything in it and type anything into it — as you, with your permissions. So attach only as yourself, share only with people you would hand your actual keyboard (chapter 9 gives sharing its own care), and detach or lock a session you walk away from. It is stated here, at the front, because every later chapter makes attaching easier — and easy should not mean careless.

A first taste

After installing (chapter 3), the whole idea fits in four commands:

screen -S work
# ... do things, then press Ctrl-A, then d, to detach ...
screen -ls
screen -r work

The first starts a session named work. The keystrokes Ctrl-A d detach you — Screen's commands nearly all begin with that Ctrl-A prefix, which chapter 2 explains. screen -ls lists the sessions waiting for you, and screen -r work reattaches.

Check: screen -ls while detached shows the session marked as detached, as in the lab's transcript screen-lab/transcripts/t01-detach-reattach.txt:

There is a screen on:
    23237.work  (10/27/26 03:06:33) (Detached)
1 Socket in /run/screen/S-lab.

Who it is for

The person who administers a machine that is not in the room. The person whose connection is good but not perfect, and whose jobs are long. The person who has ever typed nohup hopefully and then wanted to see the job again, not just trust that it lived. Screen asks little: it is one small, old, stable program, present on or installable to nearly every Unix-like machine, and it has worked essentially the same way for decades — which is why the crusty server in the corner, the one nobody dares to upgrade, almost certainly has it.

What it is not

Screen is not a window manager for your desktop: its windows are terminal sessions, not graphical programs. It is not a remote-access tool by itself: it does not carry your connection across the network — SSH does that, and Screen lives at the far end of it (chapter 10). It is not a record of your work: when the machine reboots, sessions end like everything else (chapter 13 is honest about this and its other limits). And it is not the only multiplexer: chapter 12 meets tmux, its younger and more popular neighbour, and says plainly which jobs each does better.