The screen command is a used to launch and arrange multiple terminal shells within a single shell.
It is mainly used for two purposes:
- It can be used to run long-running commands on remote servers.
- It can be used to organise multiple shells and allow you to navigate between them.
Commands
All screen commands need to be prefixed by an escape key, which is Ctrl-a
by default.
Command | Category | Description |
---|---|---|
screen | Basic | Starts a new session |
screen -S <session_name> | Basic | Starts a new session with session name |
screen -ls | Basic | Lists running screen sessions |
screen -r <session_name> | Basic | Attach to a running session with name |
screen -d <session_name> | Basic | Detach a running session with name |
screen -r -d <session_name> | Basic | Attach to a screen that is already attached |
Ctrl-a d | Exiting | Detach |
Ctrl-a D D | Exiting | Detach and logout (fast way to exit screen) |
Ctrl-a : | Exiting | Quit and exits all of the programs in screen |
Ctrl-a esc | Scrolling | Enter scrolling mode |
Ctrl-u | Scrolling | Scroll Up |
Ctrl-d | Scrolling | Scroll Down |
esc esc | Scrolling | Exit scrolling mode |
Ctrl-a c | Window Management | Create new window |
Ctrl-a Ctrl-a | Window Management | Change to last-visited active window |
Ctrl-a <number> | Window Management | Change to window by number (only 0-9) |
Ctrl-a ' <number_or_name> | Window Management | Change to window by number or name |
Ctrl-a n | Window Management | Change to next window in list |
Ctrl-a p | Window Management | Change to previous window in list |
Ctrl-a " | Window Management | Displays list of windows, allowing to select window to change into |
Ctrl-a A | Window Management | Rename current window |
Ctrl-a k | Window Management | Kill current window |
Ctrl-a \ | Window Management | Kill all windows |
Ctrl-a a | Misc | Send Ctrl-A to screen within screen, useful when working with screen within screen |
Posted on September 06, 2021