Table of Contents
screen is a terminal multiplexer program used to manage multiple windows and sessions within a Unix or Linux terminal. It provides users with the ability to run multiple processes in the same terminal window, continue sessions if disconnected, control processes running on a remote server, and run processes in the background, among other advantages.
When using screen, you can create and switch between multiple “screens” within the same terminal window. This allows you to manage several tasks simultaneously. Additionally, screen sessions can be saved and later restored.
screen is usually pre-installed on many Linux distributions. However, if it’s not installed on your system, you can easily install it using the package manager for your specific distribution. Here are example commands for popular Linux distributions:Debian/Ubuntu-based systems (using apt):
sudo apt update
sudo apt install screenRed Hat/Fedora-based systems (using dnf or yum):
sudo dnf install screen # For Fedora 22 and later versions
# or
sudo yum install screen # For Fedora 21 and earlier versionsCentOS-based systems (using yum):
sudo yum install screenopenSUSE-based systems (using zypper):
sudo zypper install screenArch Linux-based systems (using pacman):
sudo pacman -S screenBy using the above commands, you can install screen on your system. Once the installation is complete, you can start a screen session by using the screen command in a terminal window.
Here are some basic commands for using screen:
- Create a Screen:
screen - List Screens:
screen -ls - Switch to the Next Screen:
Ctrl-a n - Switch to the Previous Screen:
Ctrl-a p - Create a New Screen:
Ctrl-a c - Switch Between Screens:
Ctrl-a " (double quote) - Close a Screen:
exit - Save a
screenSession:screen -S session_name -X screen - Restore a
screenSession:screen -r session_name
These commands cover the basic usage of screen. You can refer to the comprehensive documentation of screen by using the man screen command for more details and advanced features.
Basic screen Commands:
- Attach to a Specific
screenSession:screen -r session_name - Create a New Window:
Ctrl-a c - Switch to the Next Window:
Ctrl-a n - Switch to the Previous Window:
Ctrl-a p - List Open Windows:
Ctrl-a w - Detach from the Current
screenSession (Leave it Running in the Background):Ctrl-a d - Terminate the Current
screenSession:exit
Advanced screen Commands:
- Rename the Current
screenSession:Ctrl-a A - Scrollback Mode (Enter Copy Mode):
Ctrl-a [ - Toggle Logging of the
screenSession:Ctrl-a H - Lock the Terminal:
Ctrl-a x - Split the Terminal Horizontally:
Ctrl-a S - Split the Terminal Vertically:
Ctrl-a | - Toggle Focus Between Split Regions:
Ctrl-a Tab - Close the Region that the Cursor is In:
Ctrl-a X
Saving and Restoring screen Sessions:
- Save the
screenSession:screen -S session_name -X screen - Restore a Saved
screenSession:screen -r session_name
This cheat sheet covers basic and some advanced commands for using screen. Adjustments might be needed based on your specific use case and screen configuration. For more detailed information, you can refer to the man screen command.