GNU Screen

June 29, 2026 ยท View on GitHub

The classic terminal multiplexer.

Key Points

  • horizontal and vertical screen splitting
  • built-in serial and telnet support which tmux lacks
  • status bar requires config
  • dynamic term titles requires config

Several Linux distributions are moving to Tmux which is another newer alternative.

Tip: embedding multiplexers

You can run one terminal multiplexer inside another.

eg. on a remote SSH session inside another multiplexer on your local machine.

By using screen at one layer and tmux at another, you can avoid embedded keybindings clashes and having to double escape keybindings all the time to send them through to the embedded multiplexer.

Commands

Start a basic screen session:

screen

Ctrl-a w after this command to show the status bar to see you're inside screen.

List running screens:

screen -ls
  • Start screen with options:
    • -D - detaching it from another terminal
    • -R - and reattaching it here
    • -A - adjusting the height and width to the current terminal
screen -DRA

Multi-attach to an already attached screen (useful to screen your screen with colleagues' terminals to follow along):

screen -x

Open new screen pane at number $num or next highest available:

screen $num

Screen Config

$HOME/.screenrc

Screen requires a good configuration to make it more usable, such as:

  • showing a permanent status bar along the bottom to see which screen terminal number you're in
  • dynamic term titles (what command each term is running)
  • custom keybindings

(Tmux has this by default).

See my advanced screen config here:

HariSekhon/DevOps-Bash-tools - configs/.screenrc

KeyStrokes

Ctrl-a is the default primary keybinding action key prefix, followed by the next key.

Escape the shell key of Ctrl-a to jump to the start of the line by doing Ctrl-a , a.

ActionKeystrokes
Create a new screenCtrl-a , c
Switch to the next screenCtrl-a , n
Switch to the previous screenCtrl-a , p
Jump to screen numberCtrl-a , <num>
Jump to screen number greater than 9Ctrl-a , ', <num>
Jump to last screen numberCtrl-a , Ctrl-a
List screens and jump to menu selected oneCtrl-a , "
Rename screenCtrl-a , A
Renumber screen
(will swap position with the other screen
if already on of that number)
Ctrl-a , :number <num>
Detach from the current screen
(shells stay running, can reattach later using command below)
Ctrl-a , d
Reattach to a detached screenscreen -r
Split the terminal horizontallyCtrl-a , S
Split the terminal vertically
(requires patching, only Mac / Debian / Ubuntu seem to have this)
Ctrl-a , |
Switch between split screensCtrl-a , Tab
Unify on current splitCtrl-a , Q
Remove the current splitCtrl-a , X
Resize the current split regionCtrl-a , :resize <number>
Enter Scroll / Copy modeCtrl-a , [
Search backwards in the scrollback buffer?
Search forwards in the scrollback buffer/
Next search matchn
Copy text in scrollback mode to buffer - Start / Stop copy sectionSpace to begin marker, select text, Space to end marker to copy to buffer
Paste text from bufferCtrl-a , ]
Jump backwards one screen in scrollback buffer (or use arrow keys)Ctrl-b
Jump forwards one screen in scrollback bufferCtrl-f
Jump to top line in current screen of scrollback bufferH
Jump to middle line in current screent of scrollback bufferM
Jump to bottom line in current screent of scrollback bufferL
Send a literal Ctrl-aCtrl-a , a
Text Screenshot to ~/hardcopy.$WINDOW
Overwrites this same text file each time called
Ctrl-a , h
Append Start / Stop screen log to ~/screenlog.$WINDOWCtrl-a , H

Useful Scripts

From DevOps-Bash-tools repo:

Dump Screen Terminal Output to File and Stdout

screen_terminal_to_stdout.sh  # screen args such as window number

Retains the temp file if this environment variable is set to any value:

export SCREEN_TERMINAL_NO_DELETE_TEMPFILE=1

You can pass screen options as args such as:

    -S <session_name>
    -p <window_number>

See window numbers using your Ctrl-A + w hotkey combo or in stdout via this command:

screen -S [<session_name>] -Q windows

Dump Screen Terminal Output to Clipboard

Uses the above script screen_terminal_to_stdout.sh combined with the copy_to_clipboard.sh portable script for Mac and Linux to send the terminal output straight into the clipboard ready to paste out to AI.

screen_terminal_to_clipboard.sh  # screen args such as window number

This one is quicker and convenient to use for quickly pasting your terminal results back to an AI LLM or if you want to share the file as it automatically retains the tempfile.

Ported from private Knowledge Base page 2012+ (should have had earlier notes)