Screen Command Practice
GNU Screen is the classic terminal multiplexer that keeps your shell sessions alive in the background and lets you split your terminal into multiple windows. This track drills both the CLI commands for attaching/detaching sessions and the essential Ctrl+a shortcuts required to navigate windows and regions efficiently.
Command Reference
misc
| Command | Description |
|---|---|
Ctrl+a ? | Display the help screen showing all key bindings. |
Ctrl+a d | Detach from the current Screen session, leaving it running in the background. |
Ctrl+a ] | Paste the text copied from the scrollback buffer. |
Ctrl+a [ | Enter copy/scrollback mode to view history and select text. |
Ctrl+a H | Toggle logging of the current window's output to a file (screenlog.0). |
Ctrl+a \ | Kill all windows and terminate the Screen session completely. |
Ctrl+a x | Lock the screen session, requiring a password to unlock. |
cli
| Command | Description |
|---|---|
screen -S <name> | Start a new Screen session with a specific name, making it easier to identify later. |
screen -ls | List all currently running Screen sessions and their states (Attached or Detached). |
screen -r <name> | Resume (attach to) a detached Screen session. |
screen | Start a new unnamed Screen session. |
screen -x <name> | Attach to a session that is already attached elsewhere — allows multiple users to view and type in the same terminal. |
screen -d -r <name> | Forcefully detach a session if it is running elsewhere, and immediately attach to it here. |
screen -wipe | Remove dead sessions from the session list (e.g., sessions where the host crashed). |
screen -X <command> | Send a screen command to a running session without attaching to it. |
window
| Command | Description |
|---|---|
Ctrl+a c | Create a new window with a shell and switch to it. |
Ctrl+a n | Switch to the next window. |
Ctrl+a p | Switch to the previous window. |
Ctrl+a w | Show the list of windows briefly in the status line at the bottom of the screen. |
Ctrl+a A | Prompt for a new name to rename the current window. |
Ctrl+a " | Display a selectable menu list of all windows. |
Ctrl+a ' | Prompt for a window name or number to switch to. |
Ctrl+a Ctrl+a | Toggle rapidly between the current and the most recently used window. |
Ctrl+a k | Kill the current window and all programs running inside it. |
region
| Command | Description |
|---|---|
Ctrl+a Tab | Move the input focus to the next region. |
Ctrl+a X | Kill the current region (does not kill the window running inside it, just hides the split). |
Ctrl+a S | Split the current region horizontally into two regions. |
Ctrl+a | | Split the current region vertically into two regions. |
Ctrl+a Q | Kill all other regions, leaving only the current one visible (maximises it). |
Ctrl+a :resize +N | Enter the command mode to increase the size of the current region by N lines. |
Key Use Cases
- Start a long-running script and detach with Ctrl+a d to keep it running after you log out
- Reattach to an existing background session using screen -r
- Share a terminal session with another user in real-time using screen -x
- Split the terminal display horizontally into regions using Ctrl+a S
- Navigate between multiple virtual windows within a single SSH connection
- Scroll back through output history using Screen's copy mode (Ctrl+a [)
Frequently Asked Questions
What is the difference between Screen and Tmux?
Both are terminal multiplexers. Screen is the older, classic GNU utility that uses Ctrl+a as its default prefix and refers to splits as 'regions'. Tmux is newer, uses Ctrl+b by default, calls splits 'panes', and has a more scriptable client-server architecture. However, Screen is still pre-installed on many legacy servers.
How do I detach from a Screen session without killing it?
Press Ctrl+a followed by d. This detaches the session, leaving your programs running in the background. You can resume it later by typing 'screen -r' in your terminal.
What does screen -x do?
The -x flag attaches to a non-detached Screen session. This allows multiple users (or multiple terminals) to connect to the exact same session simultaneously, effectively sharing the screen and input.
How do I scroll up in Screen?
Press Ctrl+a followed by [ to enter Copy/Scroll mode. You can then use your arrow keys or Page Up/Down to scroll through the terminal history. Press Esc to exit the mode.
Ready to master Screen commands?
Test your muscle memory with our spaced-repetition quiz system. Free forever.
