screen
Manage detached, persistent terminal sessions
TLDR
Start a new screen session
Start a new named screen session
Start a new daemon and log the output to screenlog.x
Show open screen sessions
Reattach to an open screen
Detach from inside a screen
Kill the current screen session
Kill a detached screen
SYNOPSIS
screen [options] [command [arguments]]
screen -r [sessionid]
screen -ls
screen -d [sessionid]
screen -wipe
PARAMETERS
-S sessionname
Assigns a meaningful name to the new session.
-r [sessionid]
Reattaches to a detached screen session by ID or name.
-ls
Lists all active or detached screen sessions.
-d [sessionid]
Detaches a running screen session without killing it.
-dmS sessionname
Detaches if running and creates a new named session in detached mode.
-X sessionid command
Sends a command to a specific screen session (e.g., 'stuff' for typing).
-RR
Reattaches to a session if one exists; otherwise, creates a new one.
-wipe
Removes dead screen session sockets from the system, cleaning up.
-v
Displays the version and copyright information for screen.
-h
Displays a brief help message with common options.
DESCRIPTION
screen is a powerful GNU utility that allows users to manage multiple independent terminal sessions within a single physical terminal or SSH connection. It serves as a "terminal multiplexer," providing a robust way to keep processes running persistently even if the user disconnects, making it invaluable for long-running tasks, remote server management, and ensuring continuity during network interruptions. Users can detach from a session and reattach later from the same or a different location, preserving the state of all running programs. This capability is particularly useful for sysadmins and developers working on remote servers, preventing work from being lost due to dropped connections. Furthermore, screen supports sharing sessions among multiple users, enabling collaborative work where several people can view and interact with the same terminal session simultaneously. Each screen session can contain multiple "windows," each running a separate shell or program, allowing for efficient task switching and organization within a single terminal interface. It's a foundational tool for resilient command-line work.
CAVEATS
screen has a notable learning curve, especially concerning its default keybindings which often use Ctrl+a as a prefix. Users might find it less intuitive initially compared to newer multiplexers. Its configuration can be complex, relying heavily on the .screenrc file for advanced customization. While powerful for session sharing, proper security measures should be considered when multiple users can access the same session.
<B>COMMON IN-SESSION KEYBINDINGS</B>
Inside a screen session, commands are typically prefixed with Ctrl+a (or Ctrl+b for some installations). Some common keybindings include:
Ctrl+a c: Create a new window.
Ctrl+a n: Go to the next window.
Ctrl+a p: Go to the previous window.
Ctrl+a k: Kill the current window.
Ctrl+a d: Detach the current screen session.
Ctrl+a [num]: Switch to window number [num].
Ctrl+a ": Display a list of windows for selection.
Ctrl+a ?: Show all key bindings.
<B>CONFIGURATION FILE (.SCREENRC)</B>
The behavior of screen can be extensively customized via its configuration file, typically located at ~/.screenrc. This file allows users to set default options, define custom keybindings, auto-start programs in specific windows, and manage visual aspects like the hardstatus line. It's a powerful tool for tailoring screen to individual workflows and automating session setup.
HISTORY
GNU Screen was first released in 1987 by Oliver Laumann and Carsten Weinhold, with further development by others within the GNU Project. It predates many modern terminal multiplexers and established the paradigm of persistent terminal sessions. For decades, it was the de-facto standard for managing long-running processes on remote servers, playing a crucial role in systems administration and development before alternatives like tmux emerged. Its longevity speaks to its robust and reliable design and its continued widespread use.