Detailed and comprehensive installation tutorial and usage of Screen

Screen can greatly improve terminal usage efficiency and is an essential skill for Linux system management and operation and maintenance. When we turn on Screen, as long as the Screen process is not terminated, the sessions running inside it can be restored. Even if the network connection is interrupted, users can re-enter the opened Screen and control the interrupted session, including restoring or deleting it.

1. Introduction to Screen

Screen is a very useful terminal reuse tool under Linux system. Its main functions and usage are as follows:

  1. Session management: You can run multiple terminals simultaneously within a screen session and switch between multiple terminals freely.

  2. Session recovery: The screen session can be restored at any time after being cut off, and the program that remains running as it is will not be interrupted.

  3. Remote operation: You can remotely connect to a screen session and access the same screen from different machines.

  4. Multi-window: A screen can create and manage multiple windows for running different programs.

  5. Window and shell management: Supports window renaming, numbering, and switching; supports shell background and foreground switching.

  6. Copy and paste: Supports screen scrolling and scrolling back, and can copy screen content to the pasteboard.

  7. Access control: A screen can be password protected to prevent unauthorized access.

2. Install Screen

1. root authority

Users with root permissions can use the following command to install directly:

sudo apt install screen

2. No root permissions

If you do not have root permissions, you need to download the Screen source code package for installation. First download the source code package. The address link is: Add a link description , find the corresponding version and click to download it.

as follows:

Insert image description here

2.1. Possible version problems

I first downloaded version 4.9.0, but some problems occurred during the subsequent installation process. The specific problems are as follows:

./configure: No such file or directory

Refer to other tutorials and switch to version 4.6.2 and the installation is successful. If you don’t believe it, you can try other versions. If the installation can be successful, please leave a message to share and discuss! ! !

3. Unzip the Screen source code package

Go to the path where the decompressed file is located and use the following command to decompress:

tar -zxvf screen-4.6.2.tar.gz

Insert image description here

The contents of the decompressed screen-4.6.2 file are as follows:

Insert image description here

4. Installation

Enter the decompressed file path and run the following command:

./configure --prefix=/home/whq/APP/Screen4.9.0/Path/

Note: The path after modifying --prefix= is your own installation path.

The installation will be successful by following the above steps.

3. Check whether Screen is installed successfully

Open the terminal and enter the following command directly:

screen -ls

If no error is reported, the installation is successful. The sample paper is as follows.

Insert image description here

4. How to use Screen

4.1. Create a new window

screen -S session_name 

The session_name in the above command including the following command is a customized window name.

4.2. View the windows that have been created

screen -ls

4.3. Return to the XXX window

screen -r session_name

4.4. Solution to the inability to enter the original window

first step:

screen -d session_name

Step two:

screen -r session_name

4.5. Close the xxx window

screen -S session_name -X quit

4.6 Exit the current window

按下Ctrl+a,然后按下d来退出Screen,此时程序仍在后台执行。

4.7. Adjust all windows to the size of the current terminal

screen -A session_name

4.8. Take the specified Screen process offline

screen -d session_name

4.9. Specify the number of buffer lines in the window

screen -h session_name

4.10. Even if there is already a Screen job running, a new Screen job is still forced to be created.

screen -m session_name

4.11. First try to restore the offline job. If it cannot be found, create a new Screen job.

screen -R session_name

4.12. Specify the shell to be executed when creating a new window

screen -s session_name

4.13. Display version information

screen -v session_name

4.14. Check and delete unusable Screen jobs

screen -wipe session_name

5. Summary

The above is a detailed tutorial for installing Screen with and without root permissions, as well as common commands and other commands. Scholars are welcome to leave messages for discussion. It is not easy to summarize. Thank you for your support!

Guess you like

Origin blog.csdn.net/qq_40280673/article/details/132833310