How to use the Screen command in Linux

You have a workstation connected to a linux server, but the client is often disconnected suddenly or has a problem that you don’t know how to keep your program safe and able to continue working. In the following article, Taimienphi will share with you how to use the Screen command in Linux to overcome this situation. Please read and watch.

Basically the screen command allows us to open multiple shell windows in only one command window (terminal command). Keep the shell active on the server even if the connection from the client to the server is disconnected or can disconnect and reconnect the shell window from various places. It is also possible to run the shell in the background with a time-consuming program. If you are really interested in the purpose of this article, please read the following about using the Screen command in Linux with the following article.

How to use the Screen command in Linux

Install Screen.

First you should check the screen has been installed on the system yet. For most linux operating systems such as Redhat or CentOS, the screen is usually installed in the directory: / usr / bin / screen. Or use the following command to search for the screen command:

[flex@office ~]$ which screen

/ usr / bin / screen

If the screen command is not already on the system you can use yum (CentOS) or atp-get (Ubuntu) to install:

[flex@office ~]$ yum install screen


Use Screen

After installing the screen successfully, you can initialize a screen window inside a terminal as follows:

[flex@office ~]$ screen

If you want to name the screen window for convenient management, use the following command:

[flex@office ~]$ screen -S name

This time you will have a new window inside the terminal window. The interface of these two windows is the same, the difference is that the screen allows you to use some commands from the shortcut key combinations.

Command: “Ctrl-a”

To use the command keys in the first screen you press Ctrl + A. For example, Ctrl + A then you press?. Screen will display the commands that you can use with screen.

Screen key bindings, page 1 of 4.

Command key: ^ A Literal ^ A: a

break ^ B b only Q

clear C other ^ A

colon: pow_break B

copy ^[[pow_detachD[[pow_detachD

detach ^ D d prev ^ P p ^?

digraph ^ V readbuf

displays * redisplay ^ L l

fit F removebuf =

flow ^ F f reset Z

focus ^ I screen ^ C c

hardcopy h select ‘

help? silence _

You can change the default screen command keys using the file .screenrc depending on your habits. However, according to Taimienphi, the above command keys are quite convenient to use.

Exit the screen:

Command: Ctrl + A D

To exit the screen, use the following key combination: Ctrl + A D. This is a great advantage of the screen, you can exit the screen and access it anywhere, while the commands in the screen remain continue to work on the server. In the event of a sudden connection loss, the screen automatically exits to keep your program running safely on the server.

List the screen:

After exiting the screen, want to know how many screen windows are running. From the terminal window, use the following command:

[flex@office ~]$ screen -ls

There is a screen on:

31917.name1 (Detached)

31844.name2 (Detached)

2 Socket in / var / run / screen / S-flex

Access screen:

To access the screen again, in a simple case, just use a screen window, then you can use the following command:

[flex@office ~]$ screen -r

In case of multiple command windows, you can use the following command:

[flex@office ~]$ screen -x name1

Screen breaks:

There are two ways for you to turn off the screen, if you are in the screen you can use Ctrl + A K. In the case you are outside the screen, in the terminal window use the command:

[flex@office ~]$ screen -S name1 -X quit
Above are the basic commands and procedures for using screens in Linux that Taimienphi wants to share with you so that you can apply them in managing touch devices connected to computers running Linux operating system.


Add a Comment

Your email address will not be published. Required fields are marked *