Home Linux ServerTools How to use Screen on Linux

How to use Screen on Linux

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In this tutorial, AZDIGI will show you how to use Screen on Linux, an extremely useful software that every administrator needs to know.

I. Introduction

You are administering a remote Linux system via SSH, in some cases, your system is running a process and it takes a lot of time but you have to leave the office and still want to keep track of that progress at home. At this point, you will need to use a software called Screen, a software that most Linux admins use and find very useful. So what is Screen software?

Screen, also known as GNU Screen, is a terminal multiplexer. In other words, it means you can start a connected session and then open any number of windows (virtual terminals) inside that session. Processes running in that session will continue to run even if our window is disconnected. And you can completely name these connections so that you can reconnect at any time.

To know how to use Screen on Linux, please see the next part of the article.

II. How to use Screen on Linux

To use Screen on Linux, follow these 3 steps.

Step 1: SSH into your Linux system

To use Screen on Linux, we first need to SSH into your VPS/server. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSH, we continue with step 2 to perform test commands and install Screen.

Step 2: Check if there is a Screen on your Linux server

First, you need to determine if the screen software is installed on your system. Currently, in most Linux operating systems such as Redhat and CentOS, the Screen program is usually pre-installed in the directory: /usr/bin/screen. To determine if Screen is installed on your system, use the following command:

AZDIGI Tutorial
which screen
    

If the returned result looks as below, the system already has Screen:

AZDIGI Tutorial
/usr/bin/screen
    

Otherwise, if not installed, it will be as follows and we must continue to run the installation command:

AZDIGI Tutorial
/usr/bin/which: no screen in (/root/exec -l /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
    

Step 3: Install Screen on Linux

If you using CentOS or Fedora, you can use the following command to install:

AZDIGI Tutorial
sudo yum install -y screen
    

If you are using Ubuntu or Debian, you can use the following command:

AZDIGI Tutorial
sudo apt update
sudo apt install screen
    

Once installed, we can use the following command to check the installed version of the Screen.

AZDIGI Tutorial
screen --version
    

Here is my result.

screen on linux

Step 4: Use Screen on Linux

Once installed on the system, use the following command to create a Screen window inside a terminal as follows:

AZDIGI Tutorial
screen
    

If you want to name the Screen window for easy management, use the following command:

AZDIGI Tutorial
screen -S name
    

You can change “name” to the name you want.

You will now have a new window inside the terminal window. The interface of these two windows is the same, the difference is that Screen allows you to use some commands from shortcut keys.

You can refer to how to use these shortcuts at the following link:

Exit Screen:

To exit the screen, you just need to turn off the SSH software or turn off the Terminal. This is the great advantage of Screen, you can exit the screen and access it again anywhere, while the commands in Screen continue to work on the server. In the event of a sudden connection loss, Screen will automatically exit to keep your program safely running on the server.

Screen List:

After exiting Screen, want to know how many screen windows are running, from a terminal window, use the following command:

AZDIGI Tutorial
screen -ls
    

Continue using the previously created Screen:

In case you only have 1 Screen, you can quickly use the following command:

AZDIGI Tutorial
screen -r
    

In case there are multiple Screens running, use the command below:

AZDIGI Tutorial
screen -ls
screen -x name
    

With the first command to view the list, and command 2 to continue to the Screen named “name”, this part will change if you have created a Screen with a different name.

Turn off Screen:

To turn off a Screen, we use the command:

AZDIGI Tutorial
screen -S name -X quit
    

Remember to change name to the Screen name you want to turn off.

So you already know how to basic use Screen on Linux.

III. Summary

So AZDIGI has completed the basic use of Screen on Linux. More information if you don’t know, all hosting packages at AZDIGI open SSH and the SSH port will be 2210. With SSH we can completely use Screen comfortably.

Hope this article will be of help to you. Wishing you success! See more useful articles about VPS at the following link:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign