How to Use Linux Screen Linux

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 –

Linux Screen

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

  • Ctrl+a c Create a new window (with shell)
  • Ctrl+a ” List all window
  • Ctrl+a 0 Switch to window 0 (by number )
  • Ctrl+a A Rename the current window
  • Ctrl+a S Split current region horizontally into two regions
  • Ctrl+a | Split current region vertically into two regions
  • Ctrl+a tab Switch the input focus to the next region
  • Ctrl+a Ctrl+a Toggle between the current and previous region
  • Ctrl+a Q Close all regions but the current one
  • Ctrl+a X Close the current region

 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

  1. Type screen on the command prompt
  2. Run the desired program
  3. Use Ctrl-a+Ctrl-d to detach from the screen session
  4. Type screen-r to reattach to the screen session

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

Credentials

Quick Connect With Us


    captcha
    reload