Cheat Sheet: Screen

The screen command is a used to launch and arrange multiple terminal shells within a single shell.

It is mainly used for two purposes:

  1. It can be used to run long-running commands on remote servers.
  2. 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.

CommandCategoryDescription
screenBasicStarts a new session
screen -S <session_name>BasicStarts a new session with session name
screen -lsBasicLists running screen sessions
screen -r <session_name>BasicAttach to a running session with name
screen -d <session_name>BasicDetach a running session with name
screen -r -d <session_name>BasicAttach to a screen that is already attached
Ctrl-a dExitingDetach
Ctrl-a D DExitingDetach and logout (fast way to exit screen)
Ctrl-a :ExitingQuit and exits all of the programs in screen
Ctrl-a escScrollingEnter scrolling mode
Ctrl-uScrollingScroll Up
Ctrl-dScrollingScroll Down
esc escScrollingExit scrolling mode
Ctrl-a cWindow ManagementCreate new window
Ctrl-a Ctrl-aWindow ManagementChange to last-visited active window
Ctrl-a <number>Window ManagementChange to window by number (only 0-9)
Ctrl-a ' <number_or_name>Window ManagementChange to window by number or name
Ctrl-a nWindow ManagementChange to next window in list
Ctrl-a pWindow ManagementChange to previous window in list
Ctrl-a "Window ManagementDisplays list of windows, allowing to select window to change into
Ctrl-a AWindow ManagementRename current window
Ctrl-a kWindow ManagementKill current window
Ctrl-a \Window ManagementKill all windows
Ctrl-a aMiscSend Ctrl-A to screen within screen, useful when working with screen within screen

Posted onĀ September 06, 2021