Screen remote session management tool installation tutorial

Source: Internet
Author: User
I wonder if you have ever encountered this problem: using SSH to connect to the server, when compiling a program (such as LNMP one-key installation package), the network is abnormal or other factors cause a sudden disconnection, the remote command will also stop and can only be reconnected before running. This article teaches you how to use the screen command to avoid the above problems. ScreenScreen is a full-screen window manager that allows multiple processes to reuse one physical terminal. You can

I wonder if you have ever encountered this problem: using SSH to connect to the server, when compiling a program (such as LNMP one-key installation package), the network is abnormal or other factors cause a sudden disconnection, the remote command will also stop and can only be reconnected before running. This article teaches you how to use the screen command to avoid the above problems.


Screen

Screen is a full-Screen window manager that allows multiple processes to reuse one physical terminal.

You can create multiple screen sub-sessions in one screen session. in each screen session (or sub-session), it is like operating a real telnet/SSH connection window.


1. install screen

Some CentOS systems do not have built-in screen. the installation method is as follows:


yum install screen

First, run the screen command in SSH. if the prompt screen: command not found is displayed, run the above command in ssh. If not, enter exit to exit.


2. create a screen session

Scenario: to download and install the LNMP one-key installation package in CentOS, run the following command:


screen -S kwxgd

The preceding command creates an SSH session named kwxgd.

After you press enter, the system will automatically jump to the screen session named kwxgd, where you can execute the LNMP one-key installation package command.


3. temporarily exit the screen session

(But keep the one-click LNMP installation package command running in screen)

InPress the shortcut key in the SSH window: Ctrl + a d (press Ctrl, press a in sequence, and then press d)You can exit the screen session named kwxgd.

When you temporarily leave the screen session, the screen session will not stop because it leaves, and the process that is running (such as compiling the LNMP one-key installation package) will continue to run, the advantage of screen is that you can execute multiple tasks in the same ssh window. for example, you can start a new Screen session to install NET-SNMP. Of course, you can temporarily close the ssh window and do other things.


4. re-read the screen session

There are two ways to re-read the screen session


(1) read data by screen name (such as the previously created kwxgd.
screen -r kwxgd

Run the preceding command in SSH to read the screen session. if you forget the name of the previously created screen session, you can query the running screen session in the following way.


(2) read the screen session through the screen session ID
screen -ls

Run the above Command in SSH to read the screen session in progress and list the IDCs.

If the name is too long or too complex, you can open the screen session by using the ID.


screen -r 3528

For example, if you want to read kwxgd and the ID number is 3528, run the command on SSH.


5. disable screen sessions

If you no longer need the current screen session, you canExecute exitThe prompt [screen is terminating] indicates that the screen session has been successfully closed (not stored in memory). if necessary, rebuild the screen session in step 1.


6. screen shortcut

As previously mentioned, Ctrl + a d can temporarily exit the current screen session, while screen also provides other shortcut keys.

Ctrl + a c: Create a subsession in the current screen session
Ctrl + a w: subsession list
Ctrl + a p: previous subsession
Ctrl + a n: next sub-session
Ctrl + a 0-9: switch between 0th and 9th sub-Sessions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.