To resume a detached GNU Screen session in Linux, run screen -r from a terminal. If only one session is detached, Screen reattaches it immediately; if several are running, Screen prints a list and you must supply the session name or PID, for example screen -r 12345.pts-0.hostname. The key condition is that the session must still exist on the same machine and be owned by the same user account that created it. Sessions don't survive a reboot, and a session that shows as Attached rather than Detached needs a different command before it will come back to your current terminal.

That's the short version. The rest of this article covers what to do when the plain command fails, how to tell a detached session from a dead one, how to resume sessions created by other users or on other machines, and how to avoid the most common reattachment mistakes.

What "detached" actually means in Screen

GNU Screen runs a program in a pseudo-terminal that persists independently of the terminal window you launched it from. When you press Ctrl+A then D, Screen detaches: the process keeps running in the background, but your current terminal returns to the shell prompt. The session is still alive, still consuming memory and CPU for whatever it's running, and still reachable with screen -r.

This is different from closing the terminal window with the X button or losing an SSH connection without detaching. In many of those cases the session may be killed by SIGHUP, depending on how Screen was configured and whether it was started as a login shell. Modern Screen versions handle hangup reasonably well, but the cleanest habit is always to detach deliberately with Ctrl+A, D.

A session can be in one of three practical states when you look for it:

Detached: no terminal is currently displaying it. screen -r will work. Attached: another terminal (or the same one) is currently displaying it. screen -r will refuse with a message like "There is a screen on ... Attached". Dead or gone: the process ended, the session was killed, or the machine rebooted. No reattachment is possible.

Knowing which state you're in determines the command you need.

The basic resume procedure, step by step

Before you begin, you need three things: a terminal on the same Linux machine as the session, the same user account that created it, and the screen package installed (it usually is, but screen --version confirms it).

1: List your sessions. Run screen -ls. You'll see output like There is a screen on: 12345.pts-0.myhost (Detached). The number before the dot is the PID; the full string 12345.pts-0.myhost is the session identifier. 2: Reattach if there's exactly one detached session. Run screen -r. Screen connects you to it and you see the program exactly as you left it, cursor position and scrollback intact. 3: Reattach by identifier if there are several. Run screen -r 12345.pts-0.myhost, substituting the identifier from step 1. You can use just the PID portion (screen -r 12345) as long as it's unambiguous. 4: Verify success. Your prompt or running program should reappear. Press Ctrl+A then " to see the session's window list, or Ctrl+A then W to list windows at the bottom of the screen. 5: Detach again when done. Ctrl+A, D returns you to the shell while leaving the session running.

If screen -ls prints "No Sockets found," there is nothing to resume under your account. That's a stop-and-investigate condition, not something to force with -D.

When screen -r refuses: attached, multi-user, and stale sockets

The single most common failure is the "Attached" message. This happens when a session is already being displayed somewhere—often an old SSH connection you thought had closed, or a second terminal tab. You have three options:

Find the other terminal and detach it there with Ctrl+A, D, then resume normally. Force-detach from elsewhere with screen -d -r . The -d detaches the session from its current display, and -r attaches it to yours in one step. This is the standard fix when a session is orphaned on a dead connection. Use -D -r if the session is genuinely stuck: -D is like -d but also sends a hangup, which can clear a wedged terminal.

There's a subtle case here worth flagging. If the attached terminal's network connection dropped without closing the TCP session cleanly, Screen may still believe the session is attached even though nobody is watching. screen -d -r is the correct and safe remedy; the running programs are not interrupted.

Another failure mode is a stale socket file. Screen keeps its sockets in /run/screen/S-/ (or /var/run/screen/... on older systems). If a machine crashed or a session was killed uncleanly, a socket file may remain with no process behind it. screen -ls shows these as (Dead ???) or similar. screen -wipe removes dead sockets so your listing is clean. It does not resurrect anything.

Resuming sessions across users and machines

Screen sessions belong to the user who created them, and by default only that user can attach. If you need to hand a session to a colleague or resume one under a different account, the supported mechanism is a multiuser session:

1: Inside the session, press Ctrl+A, then type :multiuser on and press Enter. This enables multiuser mode. 2: Still inside, add the other user with :acladd username, substituting their actual login name. 3: From the second account, run screen -r /. The syntax is the owner's username, a slash, then the identifier from screen -ls.

Treat multiuser mode as a real permission change, not a convenience toggle. Only add accounts you trust, and turn it off with :multiuser off when you're done. It is not a way to gain access to sessions you don't own; the owner must grant it from inside the session.

To resume a session on a different machine, Screen alone cannot help—sessions are local to the host. The usual pattern is to SSH into the original machine and run screen -r there. If the original machine is gone, the session is gone with it, which is why pairing Screen with a durable host (or moving to tmux with a similar workflow) matters for long jobs.

Screen versus tmux: same goal, different resume command

screen -r is specific to GNU Screen. If your team has standardized on tmux, the equivalent is tmux attach or tmux attach -t , with sessions listed by tmux ls. The two tools solve the same problem—keeping terminal programs alive across disconnects—but they are not interchangeable, and their session stores are separate. Running screen -ls will never show tmux sessions, and tmux ls will never show Screen sessions.

The practical criteria for choosing between them come down to defaults and ecosystem:

Multiple windows and panes: tmux has them natively with a friendlier default layout; Screen offers windows via Ctrl+A, C, and it splits awkwardly without config file tuning. Configuration portability: Screen's .screenrc is small and widely documented; tmux's .tmux.conf is more expressive but has changed syntax across versions, so version-specific instructions matter. Default keybindings: Screen's Ctrl+A prefix clashes with the shell's "move to beginning of line" shortcut, which trips up newcomers; tmux's Ctrl+B prefix has fewer conflicts. Availability on minimal systems: Screen is more likely to be preinstalled on older or minimal distributions; both are in standard package repositories.

One fair comparison caveat: neither tool preserves a session across a reboot unless you add something like tmux-resurrect (tmux) or a similar plugin. Both are session multiplexers, not job persistence layers.

How the reattach actually works, and why that matters for recovery

When you run screen -r, the client connects over a Unix domain socket to the Screen server process holding the session. The server re-renders the virtual terminal and hands your keyboard input to the running program. Nothing restarts; the shell and its child processes never noticed you left.

This mechanism explains the failure modes. If the socket is unreachable (wrong user, wrong host, wrong path), the client cannot connect. If the server process died (out-of-memory killer, reboot, explicit kill), the socket is stale and reattachment is impossible. If another client already holds the connection, the server refuses a second attach unless you use -d or -x.

The -x flag deserves a mention: screen -x attaches to a session that is already attached, giving you a shared view. That's useful for pair debugging, and it's dangerous if you didn't intend to share. Don't use -x as a workaround for "I can't resume"; use -d -r instead so the old terminal is properly detached.

Practical habits that make resuming reliable

The people who rarely fight with resumption tend to follow a few patterns:

Detach before you disconnect. Always Ctrl+A, D rather than closing the SSH window. This keeps the session cleanly Detached and makes the next screen -r a one-liner.

Name your sessions. Start them as screen -S jobname so listings are readable and you can reattach with screen -r jobname instead of memorizing PIDs. This pays off when you have three sessions running on a shared host.

Keep one session per long task. Combining unrelated work into one session makes partial recovery impossible; if one program wedges the terminal, you can't resume the rest. Separate sessions let you detach or kill the broken one without losing the others.

Check screen -ls before assuming the job died. A surprising amount of "my job was killed" turns out to be a still-running session under a different username or a different host.

Remember that screen doesn't survive reboots. If you need jobs to survive a machine restart, Screen is the wrong tool; look at systemd services, nohup, or at depending on the job.

A quick worked troubleshooting table

The table below maps symptoms to the most likely cause and the smallest reversible action. Use it to move from diagnosis to fix without guessing.

Symptom Likely cause First action
No Sockets found No sessions under your account, or wrong host Confirm username and hostname
Attached when you run -r Another terminal holds it screen -d -r
(Dead ???) in listing Stale socket from a crashed session screen -wipe, then relaunch
Cannot open your terminal Running inside a non-interactive context (cron, some IDE terminals) Run from a real interactive shell
Session resumes but program is frozen Program itself is stuck or waiting on input Ctrl+C or investigate the program; resumption worked

That last row is the important distinction: a resumed session that shows a frozen program is a program problem, not a Screen problem. The reattachment succeeded. Similarly, if you resume and see your shell prompt rather than the program you expected, the program exited or crashed earlier and returned you to the shell—again, Screen did its job.

The one condition where you should stop and get help is filesystem or permission trouble: if /run/screen/ is missing, unwritable, or owned by someone else because of a broken package or a misconfigured umask, reattachment will fail in confusing ways. That's a system administration matter, not something to fix by changing ownership of system directories.

Frequently asked edge questions

Does screen -r work over SSH after a dropped connection? Yes, provided the session was detached and the server didn't kill it. If it shows as attached to the dead connection, use screen -d -r .

Can I resume a session I started with sudo? The session belongs to the user who ran screen. If you started it as root with sudo screen, you must resume as root with sudo screen -r. Running screen -r as your normal user will not find it.

What happens to a session if the machine reboots? It's gone. Screen state is in memory and in local sockets; there's no built-in persistence across reboots. Plan for this by moving critical jobs to a service manager.

Is there a way to list sessions without attaching? Yes: screen -ls lists all sessions for your user on the local machine. There's no built-in remote listing, but ssh host screen -ls works because it runs the command remotely.

The whole workflow boils down to a small vocabulary: screen -ls to look, screen -r to resume, screen -d -r to reclaim an attached session, and screen -wipe to clear dead sockets. Master those four and resumption stops being a source of anxiety.