1. home page
  2. Unclassified

[Notes] SSH virtual desktop screen

Technical reprint from: VPS Detective After fruit cat finishing. For your convenience,

Common commands

screen -S XXX Create a window. S must be capitalized, XXX is the window name

screen -r XXX Restore window.

screen -ls List all windows

Screen - D - r Kick off and restore the window

introduce

VPS Detective When I first came into contact with Linux, I was most afraid of SSH remote login Linux VPS compiling the installation program (such as installing lnmp )The network is suddenly disconnected or has to be disconnected from the remote SSH server due to other circumstances, and the remote command is also forced to stop. You can only reconnect and run again. It is believed that some VPSers have also encountered this problem. Today we will introduce a model to VPSers Remote Session Management Tools  -  Screen command

1、 What is the screen command?

Screen It is a full screen window manager that can multiplex a physical terminal between multiple processes. Screen has the concept of session. Users can create multiple screen windows in one screen session, and each screen window is like operating a real telnet/SSH connection window.

2、 How do I install the screen command?

Except for some streamlined systems or customized systems, most of them have screen commands installed. If they are not installed, the CentOS system can execute: yum install screen  ;

Debian/Ubuntu system execution: apt-get install screen  。

3、 How to use the screen command?

1. Common usage methods

Used to solve article At first, we encountered problems, such as Installing lnmp When.

1.1 Creating a screen session

You can first execute: screen -S lnmp Screen will create a session named lnmp. VPS Detective https://www.vpser.net/

1.2 Leave temporarily and keep the task or program in the screen session

When you need to leave temporarily (the program in the session will not be closed and is still running), you can use the shortcut key Ctrl+a d (that is, press Ctrl, and then press a, d)

1.3 Resume screen session

You can execute again when you return: screen -r lnmp You can restore to the working interface of the lnmp session created before leaving. If you forget or do not specify a session name at that time, you can execute: screen -ls The screen will list the existing sessions, as shown in the following figure:

11791.lnmp is the lnmp session created by the screen just now. At present, the lnmp session has been temporarily exited, so the status is Detached. When screen - r lnmp is used, the status will change to Attached. 11791 is the process ID of the screen session. You can also use the following when recovering the session: screen -r 11791

1.4 Close screen session

Execution: exit , you will be prompted: [screen is terminating], indicating that you have successfully exited the screen session. VPS Detective https://www.vpser.net/

2. Remote Demo

First, the presenter executes on the server screen -S test Create a screen session, and the audience can link to the remote server to execute screen -x test  Synchronization with the presenter will appear on the audience screen.

3. Common shortcut keys

Ctrl+a c: Create a window in the current screen session
Ctrl+a w: window list
Ctrl+a n: Next window
Ctrl+a p: Previous window
Ctrl+a 0-9: Switch between window 0 and window 9

If you have any reason, you can leave a message below this article or go to https://bbs.vpser.net Post.

>>Please indicate the source for reprinting: VPS Detective Link to this article: https://www.vpser.net/manage/screen.html

score zero , full marks 5-star
zero ticket
fabulous zero
After reading and collecting, you can find it next time
  • Copyright notice: This article is published based on the Knowledge Sharing Attribution - Sharing in the Same Way 3.0 Mainland China License Agreement. Please follow this agreement for reprinting
  • Article link: https://moe.xin/945.html [ copy ](Please indicate the source and link of this article when reprinting)
  • No relevant articles in this article
Previous:
: Next

3 comments

 gravatar

  1. It means that he knew about screen half a year ago :grin:

    #1st floor
    1. @ Tea blood Why Horse Egg QAQ is original. I left.....

  2. Linux should be practiced

    #2nd floor