How to Use Linux Screen?
Screen is a terminal multiplexer. Any number of Windows (virtual terminals) can be started inside a session. Processes will continue to run even when the window is not visible or when you get disconnected. Screen utility allows you to run long running tasks and resume the sessions even when you get disconnected or SSH session is terminated.
These days the screen package is available in most of the Linux distros. The following command checks if Screen is installed and the version of Screen.
# screen –version
The output for the command is as follows –
Installation of Screen:
The following commands installs screen on your server
Ubuntu and Debian based distros
# apt update
# apt install screen
CentOS and Fedora based distros
# yum update
# yum install screen
To start screen session, type the following command
# screen
To open screen session with a specific name
# screen –S name
You can run multiple windows in a single screen session.
To create a new windows with shell, type Ctrl+a c, the first available number from the range of 0..9 will be assigned.
The following are the most common commands for managing Linux Screen window
Detach from screen session:
# Ctrl+a d will detach the session. Tasks running in screen will continue after detaching from the session.
Reattach screen session:
# screen –ls command will show the list of screen sessions running.
The output for the command is as follows –
There are screens on:
10225.example (Detached)
10599.nodejs (Detached)
2 Sockets in /run/screens/tracker
The following command attaches to the existing screen session.
# screen –r 10225.example
Steps to get Screen started
At Velan, our server support engineers can help you install screen utility and monitor the time consuming tasks remotely on your server. We troubleshoot problems like these for our clients every day. If you are interested in our service, please fill the Quick connect form to get in touch with us