GNU Screen¶
GNU screen is a terminal multiplexer, which is a CLI tool that enables virtual terminals which you can attach and detach from, allowing you to leave commands running on the server when you log out. You can log back in and reattach to the screen session and it appears that you are right back at the original terminal.
See also tmux, which is a more modern replacement. If you haven't used tmux or screen before, use tmux unless you need a feature that screen has but tmux does not. screen has lots of technological problems under the hood, lacks sufficient docs, and has several deep security problems. EG: https://security.opensuse.org/2025/05/12/screen-security-issues.html
Examples¶
These all assume that your config has ctrl-a set up as the the command character, which is the default.
Rename a screen tab¶
Show a list of sessions¶
Detach from a screen session¶
re-attach to a specific screen session¶
Sharing your screen¶
In order to share your screen the /usr/bin/screen binary needs to be suid, which is a significant security risk.
Open three IPMI consoles¶
This snip opens several new tabs, each with a name and a start command including the name.
Open a series of new tabs and run ssh as root¶
For some reason screen doesn't like the ssh user@host syntax, so use
ssh -l
Terminal Emulation for Serial Ports¶
You must first figure out the name of the device that is connecting to your serial port, such as a USB adapter. Then use syntax such as the following:
Split Screen¶
ctrl-a S to create a split screen, ctrl-a [tab] to switch between.
The splits are destroyed when re-attaching.
.screenrc¶
Using ~/.screenrc you can define many variables to customize the look of
your screen tool, including tabs, clock and colors. Here's an example
that gives all three:
caption always "%{Mk}%?%-Lw%?%{km}[%n*%f %t]%?(%u)%?%{mk}%?%+Lw%? %{mk}"
hardstatus alwayslastline "%{kW}%H %{kB}|%{km} %l ~ %=%{km}%c:%s %D %M/%d/%Y "
Bugs¶
In Ubuntu with a Mac keyboard connected, sometimes the backspace key
functions incorrectly. set TERM=vt100 before running screen to fix
this.
Links¶
- https://security.opensuse.org/2025/05/12/screen-security-issues.html
- https://undeadly.org/cgi?action=article&sid=20090712190402: "Interview with Nicholas Marriott on tmux" includes info about why he wrote
tmuxbecause of problems withscreen.