Linux screen remote session management commands
Screen is a Multi-Window Management Program in Linux. When using SSH to remotely log on to Linux, if the connection is interrupted abnormally, the system opens a new session and cannot restore the original session. The screen tool can effectively solve this problem. Screen is a terminal multi-path Adapter. In essence, it means that you can use a single terminal window to run multi-terminal applications. Screen allows one or more users to log on to a session multiple times from different terminals and share all the features of the session (for example, you can see identical output) to implement remote assistance. It also provides a window access permission mechanism to protect the window password.
1. screen Installation
First, insert the system disk to the optical drive and mount it. The mount command is as follows (under CentOS7 ):
[Www.bkjia.com @ bkjia] # mount/dev/sr0/mnt
To install the screen program, run the following command:
[Www.bkjia.com @ bkjia] # rpm-ivh screen-4.1.0-0.21.20120314git3c2946.el7.x86_64.rpm
2. Common screen parameters
-A: All windows adapt to the new display width and height.
-C file: replaces the screen configuration file with the specified file.
-D: disconnect the terminal that connects to the screen (when using this command, the screen status must be Attached, that is, the user can be connected to the screen ).
-D: disconnect the terminal connected to the screen. The difference between-d and-D is that-D will kill the user logging on to the screen and leave it in the logout status.
-H lines: specifies the number of buffer lines in the screen window.
-List or-ls: displays all currently running screen processes.
-M: re-create a new screen process in a screen process.
-R [session]: restores the offline screen process. If there are multiple disconnected processes, you must specify [pid, tty, host ].
-R: First, try to restore the offline process. If the offline job cannot be found, a new screen process is created.
-S sockname: Specifies the name of the screen job.
-V: displays screen version information.
-Wipe: checks all current screen jobs and deletes unusable screen jobs.
-X: add to screen job (multi-screen display ).
-D-r: connect to a screen process. If the process is attached, kill the remote user and connect again.
-D-r: connect to a screen process. If the process is attached, kill the remote user and ask him to log out Before connecting.
3. simple use of screen
(1) screen-S test: to create a screen job, you can directly run the screen command to create it. However, the screen job created in this way has no name, we recommend that you use the-S command to specify the job name.
(2) screen-list or screenls: list the left and right screen jobs currently running.
(3) Cral + a + d: the shortcut key that is removed from the current screen job.
(4), screen-r test: restore to the screen job named test.
(5), screen-x test: add to the screen job named test.
(6) exit: exit from the current screen job.
(7) screen-wipe: Check all current screen jobs and delete screen jobs that are no longer available.
※Important summary ※:
(1) When only one screen request is sent to the system, use screen-x to directly connect to the system for help.
(2) When using multiple screen requests on the system, you must use screen-x [SESSION] for help.
If the request name is different, specify the name of the screen to be connected.
If the request name is the same or similar, you must specify the name of the screen to be connected and the PID process ID before the process.
(3) For commands with long system backup time and long running duration, we recommend that you enable screen first and then execute it to prevent data loss and errors caused by network disconnection in the current shell.
(4) when using the program, we recommend that you use the program PID for connection.
(5) When the user's request [SESSION] is a number, we recommend using the user's PID for direct connection to reduce error generation.
(6) When the system has multiple SESSION requests, we recommend that you directly use the PID before the user SESSION for connection.
Linux Screen: Recording Screen logs
Screen details:
Linux Screen ultra-Concise tutorial
Common Screen commands in Linux
Zabbix sends Screen graphical reports by email
Linux virtual terminal command Screen usage
Linux tips: use Screen to manage your remote sessions
This article permanently updates the link address: