Screen is a terminal multiplexer for Unix-like operating systems such as Linux. It allows you to manage multiple terminal sessions within a single window or remote connection. In this guide, we’ll show you the installation steps and provide tips on how to use Screen easily.
Before installing anything on your server, be sure to run the update command for your operating system to keep your server secure and up to date.
sudo apt update && sudo apt upgrade
sudo yum update
sudo zypper update
sudo dnf update
Installing Screen is super easy—just run the appropriate command for your Linux distribution:
sudo apt install screen
sudo yum install screen
sudo zypper install screen
sudo dnf install screen
As mentioned, you can create multiple sessions with Screen. To start a new one, simply enter the following command, replacing [name] with any name you choose.
screen -S [name]
Note that the commands in this guide are case-sensitive, especially the parameter flags.
This opens a new Screen session where you can run scripts or programs that will continue running even after closing the remote connection.
You can detach from a Screen session by pressing CTRL + A followed by D, or end it by typing exit in the terminal.
You can list all active sessions/screens with screen -ls or screen -list.
To return to an existing session, use the command screen -r [name], which takes you directly to the desired session.
Screen offers many - parameter flags to customize commands. Here are the most important ones in the table:
| Flag | Alias | Info |
|---|---|---|
| -v | Shows the current Screen version | |
-S [name] | Starts a new Screen session named [name] | |
| -ls | -list | Lists all running screens |
-wipe [name] | Deletes screens, optionally by name [name] | |
-r [name] | Attaches you to the Screen session [name] | |
-d -r [name] | Detaches your current session and attaches you to [name] |
Find all available parameters with screen -h – this provides a detailed overview.
Now that you know the basics, here are some shortcuts to help you manage your sessions even better. Within a Screen session, you can create multiple windows for different tasks.
All shortcuts here work only after pressing CTRL + A.
Pressing C creates a new empty window in the current directory. Switch between windows with N (next), P (previous), or " – then use the arrow keys to select the desired window.
By default, all windows have the same name (usually the shell name). You can rename windows with A.
And you can delete a window with K.
To display two windows side by side, use S for horizontal split or | for vertical split, and switch between them with Tab.
After creating a split window, switch there with Tab and open a previous window in the second view with ".
You can split as many windows as you want—but keep in mind that running many tasks in parallel can quickly increase your server’s RAM usage.