What is Screen Command in Linux? How to Use it?

Linux screen command tutorial
Linux screen command tutorial

You might have faced a situation in which you perform an uploading/downloading task on a remote server, and suddenly the connection drops, SSH terminates the session, and all your work is lost. Well, we all had faced this at some point. Aren’t we? However, today in this article, we’re gonna walk you through the process to resume the interrupted process exactly from where it stopped. There is a command called screen that allows users to resume all the failed tasks effortlessly.

Also See:

Use of Rsync Command in Linux with Example

How to Install Screen command in Linux

The screen package is coming pre-installed in most Linux operators nowadays. You can check if the screen command is pre-installed or not by the following command.

$  screen --version

OutPut:
$  Screen version 4.01.00devel (GNU) 2-May-06

If you don’t have a screen installed in your system, you can easily install it with the help of the following commands.

Install Screen on Ubuntu/Debian

$  sudo apt update $ sudo apt install screen

Install Screen on CentOS

$  sudo yum install screen

How to start the Linux Screen

Starting the Linux screen is fairly simple with the help of the screen command.

 screen

This will replace the current session with a screen session. You can type Ctrl + a ? to get the list of commands that can be used inside the session utility. (Don’t type Ctrl+A+? Type Ctrl+ A and then type ? from your keyboard.) 

View Currently running sessions in Linux Screen

You can easily view all the currently running sessions on Linux Screen by following the below command.

$  screen -ls

Output:
There are screens on:
 31765.pts-4.test (Attached)
 11564.pts-5.test (Attached)
 10510.pts-0.test (Detached)
 13292.pts-0.test (Detached)
4 Sockets in /var/run/screen/S-root.

You can restore any session by entering the session id in the following command.

$  screen -r 13292

The above command will resume the session with 13292 session ID.

That’s how you can easily use screen commands in Linux. However, We’ve written many other articles related to SSH, Linux, Commands, and other useful Linux categories that will definitely help you grow your Linux carrier. Other than this, if you’re looking for an article where you can learn all the necessary Linux Commands to start your carrier in the Linux industry, you can visit our latest article by clicking over the link above.

 

Scroll to Top