Skip to content

GNU Screen

100 commands

The original terminal multiplexer: detachable sessions, multiple windows and serial-console access.

  • terminal
  • sessions
  • serial

Install GNU Screen

sudo apt install screen

Basic Syntax3

screen

Starts a new screen session with default settings.

screen -version

Displays the installed version of GNU Screen.

screen -help

Prints a summary of command-line options and flags.

Session Management9

screen -ls

Lists all currently active screen sessions and their sockets.

screen -S [name]

Starts a new session with a specific descriptive name.

Link
screen -r [id]

Reattaches to a detached session using its process ID.

Link
screen -r [name]

Reattaches to a detached session using its session name.

Link
screen -R

Reattaches to an existing session or creates it if it does not exist.

Link
screen -d [name]

Remotely detaches a session that is currently attached elsewhere.

Link
screen -d -r [name]

Detaches a session from another terminal and reattaches it to the current one.

Link
screen -x [name]

Attaches to a session without detaching it elsewhere for multi-display mode.

Link
screen -wipe

Removes dead or crashed session sockets from the socket directory.

Link

Internal Navigation2

Ctrl+a ?

Displays a list of current key bindings and commands.

Link
Ctrl+a d

Detaches the current session and returns to the shell.

Link

Window Management9

Ctrl+a c

Creates a new window within the current screen session.

Link
Ctrl+a n

Switches to the next window in the list.

Link
Ctrl+a p

Switches to the previous window in the list.

Link
Ctrl+a [0-9]

Switches directly to the window with the specified number.

Link
Ctrl+a "

Displays an interactive list of all windows for selection.

Link
Ctrl+a w

Displays a list of windows on the status line.

Link
Ctrl+a A

Prompts to rename the current window title.

Link
Ctrl+a k

Kills the current window and its running process.

Link
Ctrl+a \

Kills all windows and terminates the screen session immediately.

Link

Region Management5

Ctrl+a S

Splits the current region horizontally into two regions.

Link
Ctrl+a |

Splits the current region vertically into two regions.

Link
Ctrl+a Tab

Switches input focus to the next region.

Link
Ctrl+a Q

Closes all regions except the currently focused one.

Link
Ctrl+a X

Closes the currently focused region.

Link

Copy and Scroll3

Ctrl+a [

Enters copy/scrollback mode to view history or select text.

Link
Ctrl+a ]

Pastes the contents of the screen buffer into the current input.

Link
Ctrl+a >

Writes the current paste buffer to a temporary file.

Link

Configuration2

screen -c [file]

Starts a session using a specific configuration file.

Link
Ctrl+a :source

Reloads the configuration file into the current session.

Link

Logging4

screen -L

Starts a session with automatic output logging enabled.

Link
screen -Logfile [file]

Defines the specific filename for the session output log.

Link
Ctrl+a H

Toggles logging on or off for the current window.

Link
Ctrl+a h

Writes a hardcopy of the current view to a file.

Link

Security1

Ctrl+a x

Locks the screen terminal requiring a password to unlock.

Link

Automation4

screen -d -m [cmd]

Starts a session in detached mode running a specific command.

Link
screen -X [cmd]

Sends a command to a running screen session without attaching.

Link
screen -X stuff

Injects keystrokes or strings into a running session window.

Link
screen -X screen

Creates a new window running a command in a remote session.

Link

Advanced Config4

defscrollback [num]

Sets the default scrollback buffer size for new windows.

Link
escape [key]

Changes the command character from Ctrl-a to Ctrl-b.

Link
hardstatus alwayslastline

Configures the status bar to always appear at the bottom.

Link
startup_message off

Disables the copyright notice screen on startup.

Link

Multi-User4

multiuser on

Enables multi-user mode for the current session.

Link
acladd [user]

Grants a specific user permission to access the session.

Link
acldel [user]

Revokes a user's permission to access the session.

Link
aclchg [user] [perms]

Modifies user permissions to read-only or write access.

Link

Internal Command3

Ctrl+a :number

Changes the current window's number to the specified value.

Link
Ctrl+a :title

Renames the current window via the command prompt.

Link
Ctrl+a :fit

Resizes the window to the current region size.

Link

Operational Workflow7

screen -q

Suppresses error messages for cleaner script output.

Link
Ctrl+a t

Displays the system time and load average.

Link
Ctrl+a v

Display the version and compilation date.

Link
Ctrl+a Z

Resets the virtual terminal to its default state.

Link
Ctrl+a *

Lists all currently connected displays.

Link
Ctrl+a _

Monitors the window for silence (inactivity).

Link
Ctrl+a M

Monitors the window for activity or output.

Link

SOC Workflow3

screen -D -m

Starts a session detached and doesn't fork a new process.

Link
Ctrl+a :logfile

Changes the log filename dynamically while running.

Link
Ctrl+a :log on

Forces logging on for evidence collection immediately.

Link

Blue Team Defense3

screen -x -X lockscreen

Remotely locks a shared session to prevent unauthorized input.

Link
vbell off

Disables the visual bell flash for stealthier operation.

Link
screen -S [name] -p [win] -X kill

Remotely kills a specific window in a session without attaching.

Link

Scripting5

screen -p [n] -X stuff

Sends a shell command to window 0 of a detached session.

Link
screen -Q windows

Queries a detached session for a list of active windows.

Link
screen -X eval

Executes multiple screen commands sequentially in one call.

Link
screen -X readreg

Reads the contents of a file into a screen paste register.

Link
screen -X paste

Pastes contents from a specific register into the window.

Link

Incident Response3

screen -S [name] -X hardcopy -h [file]

Saves the full scrollback buffer to a file for forensics.

Link
Ctrl+a :sessionname

Renames the current session to reflect incident status.

Link
Ctrl+a :wrap

Toggles line wrapping to preserve long log lines.

Link

Environment2

setenv [var] [val]

Sets an environment variable for all new windows.

Link
unsetenv [var]

Removes an environment variable for security isolation.

Link

Advanced Workflow7

layout save [name]

Saves the current split region layout configuration.

Link
layout load [name]

Restores a previously saved split region layout.

Link
layout autosave on

Automatically saves the layout when changes occur.

Link
bind [key] [cmd]

Binds a specific key to a screen command.

Link
bindkey [seq] [cmd]

Binds a keyboard function key to a screen command.

Link
screen -X colon

Forces the session to enter the command prompt mode.

Link
screen -r [name] -X

Reattaches and immediately executes a sequence of commands.

Link

Buffer Management3

Ctrl+a =

Removes the current paste buffer.

Link
writebuf

Writes the paste buffer to the exchange file.

Link
readbuf

Reads the exchange file into the paste buffer.

Link

Flow Control2

Ctrl+a f

Toggles flow control to fix frozen terminals.

Link
defflow

Sets default flow control behavior for new windows.

Link

Character Encoding2

defutf8 on

Enables UTF-8 encoding by default for new windows.

Link
Ctrl+a :utf8 on

Toggles UTF-8 encoding for the current window.

Link

Session Hierarchy2

Ctrl+a a

Sends a literal Ctrl+a to the application inside screen.

Link
screen -e^xx

Starts screen with Ctrl+x as the escape character for nested sessions.

Link

Advanced Scripting4

screen -X at

Executes a command specifically in window number 2.

Link
screen -X other

Switches the window to the previously used window.

Link
screen -X remove

Destroys the current region in split mode remotely.

Link
screen -X select

Forces the session to switch to window 0.

Link

Real World Ops4

zombie [keys]

Keeps windows open after the process dies for inspection.

Link
autodetach on

Automatically detaches the session on SIGHUP instead of terminating.

Link
pow_detach_msg

Disables the message displayed when detaching.

Link
msgminwait 0

Reduces the wait time for status messages to zero.

Link