LinuxCommandLibrary

screen

TLDR

Start a new screen session

$ screen
copy
Start a named session
$ screen -S [session_name]
copy
List active sessions
$ screen -ls
copy
Reattach to a session
$ screen -r [session_name]
copy
Detach from current session (inside screen)
$ Ctrl+a d
copy
Create a new window (inside screen)
$ Ctrl+a c
copy
Switch between windows (inside screen)
$
**Split screen horizontally**
copy
Kill current window
$ Ctrl+a k
copy

SYNOPSIS

screen [-S name] [-r [name]] [-ls] [-d] [command]

DESCRIPTION

screen is a terminal multiplexer that allows running multiple terminal sessions within a single window. Sessions can be detached and reattached, making them persistent across disconnections—essential for remote work and long-running processes.
Each screen session can contain multiple windows, each running its own shell or program. Windows can be split into regions to view multiple windows simultaneously.
Sessions persist even when you disconnect, whether intentionally or due to network issues. This makes screen invaluable for running processes on remote servers that must survive connection drops.
Copy mode allows scrolling through terminal history and copying text between windows or to the clipboard.

PARAMETERS

-S name

Create session with specified name
-r [name]
Reattach to a detached session
-R
Reattach if possible, otherwise start new session
-d
Detach a running session
-D
Detach and logout
-ls, -list
List all sessions
-x
Attach to a session that is already attached (multi-display)
-dm
Start in detached mode (for scripts)
-X command
Send command to a running session
-L
Enable logging
-h lines
Set scrollback buffer size

KEY BINDINGS

All commands are prefixed with Ctrl+a (command character):
Ctrl+a c: Create new window
Ctrl+a n/p: Next/previous window
Ctrl+a ": List windows
Ctrl+a 0-9: Switch to window number
Ctrl+a d: Detach from session
Ctrl+a k: Kill current window
Ctrl+a S: Split horizontally
Ctrl+a |: Split vertically
Ctrl+a Tab: Switch between regions
Ctrl+a X: Close current region
Ctrl+a [: Enter copy/scrollback mode
Ctrl+a ]: Paste
Ctrl+a ?: Show key bindings

CAVEATS

Screen's default configuration may conflict with some terminal features. Customize via ~/.screenrc.
The command prefix Ctrl+a conflicts with readline's beginning-of-line. Remap with escape in .screenrc if needed.
Nested screen sessions require pressing the prefix twice (Ctrl+a a) to send commands to the inner session.
For modern alternatives with more features, consider tmux.

HISTORY

Screen was originally written by Oliver Laumann in 1987 and has been maintained by the GNU project. It was one of the first terminal multiplexers and established the paradigm that tmux and others follow.

SEE ALSO

tmux(1), byobu(1), dtach(1), nohup(1)

Copied to clipboard