Linux screen Command: Persistent SSH Sessions (detach, reattach)

linux screen command - custom-screen-featured.png

Linux screen keeps processes running when your SSH client disconnects — long compiles, tail -f, or remote installs. It predates tmux but still ships on many servers and rescue images.

Alternative: tmux guide,
nohup,
SSH config.

Start a named session

Named sessions are easier to reattach after days away.

bashstart
screen -S deploy
screen -S
session

Detach without killing work

Default prefix is Ctrl+A, then D.

detach
Ctrl+A D

List and reattach

If only one detached session exists, plain screen -r works.

bashreattach
screen -ls
screen -r deploy
screen -r
screen -ls

When to use tmux instead

tmux offers panes and nicer scripting; screen is fine for one long-running command.

TipInside screen, run echo $STY to confirm you are attached to a session.
tmux
choice

Quick Reference

  • New session: screen -S name
  • Detach: Ctrl+A, then D
  • Back: screen -r name

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.