screen Command
Intermediate Process Management man(1)Terminal multiplexer for persistent sessions
👁 11 views
📅 Updated: Mar 15, 2026
SYNTAX
screen [OPTION]... [COMMAND]
What Does screen Do?
screen is a terminal multiplexer that creates persistent terminal sessions you can detach from and reattach to later. It allows running multiple shell sessions within a single terminal and keeps them alive after SSH disconnection.
screen is essential for remote server work where SSH connections may drop. Unlike nohup, screen lets you reattach to running sessions and see their output. It supports multiple windows, split views, copy/paste between windows, and session sharing.
screen has been the standard terminal multiplexer for decades. tmux is the more modern alternative with better defaults, but screen remains ubiquitous and available on virtually every Linux system.
screen is essential for remote server work where SSH connections may drop. Unlike nohup, screen lets you reattach to running sessions and see their output. It supports multiple windows, split views, copy/paste between windows, and session sharing.
screen has been the standard terminal multiplexer for decades. tmux is the more modern alternative with better defaults, but screen remains ubiquitous and available on virtually every Linux system.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -S | Name the session | screen -S myproject |
| -r | Reattach to a detached session | screen -r myproject |
| -ls | List all sessions | screen -ls |
| -d | Detach a session from another terminal | screen -d myproject |
| -d -r | Detach and reattach (force) | screen -d -r myproject |
| -dm | Start a detached session running a command | screen -dmS backup ./backup.sh |
| -x | Attach to a session (multi-display mode) | screen -x myproject |
Practical Examples
#1 Start named session
Creates a new screen session named "deploy".
$ screen -S deploy#2 Detach from session
Detaches from the current session, leaving it running in the background.
$ Ctrl+A then D
Output:
[detached from 12345.deploy]
#3 List sessions
Shows all running screen sessions.
$ screen -ls
Output:
12345.deploy (Detached)\n67890.backup (Attached)
#4 Reattach to session
Reconnects to the deploy session after SSH reconnection.
$ screen -r deploy#5 Start detached with command
Starts a background session running rsync without attaching to it.
$ screen -dmS backup rsync -av /data/ /backup/#6 Force reattach
Detaches the session from another terminal and reattaches it here.
$ screen -d -r deployTips & Best Practices
Essential key bindings: Ctrl+A is the command prefix. Ctrl+A D=detach, Ctrl+A C=new window, Ctrl+A N=next window, Ctrl+A P=previous, Ctrl+A K=kill window.
screen vs tmux: tmux has better defaults, scripting, and split-pane support. screen is more widely pre-installed. Both solve the same problem.
Dead sessions: If screen -ls shows 'Dead' sessions, clean them up with screen -wipe.
Frequently Asked Questions
How do I detach from a screen session?
Press Ctrl+A followed by D. The session keeps running and you can reattach with screen -r.
How do I reattach after SSH disconnection?
SSH back in and run screen -r to reattach. If multiple sessions exist: screen -r session_name.
What is the difference between screen and tmux?
Both are terminal multiplexers. tmux has better split-pane support, configuration, and scripting. screen is older and more widely available.
Related Commands
More Process Management Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →