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.
Table of contents
- 1. Introduction to Screen
- 2. Install Screen
- 3. Check whether Screen is installed successfully
- 4. How to use Screen
-
- 4.1. Create a new window
- 4.2. View the windows that have been created
- 4.3. Return to the XXX window
- 4.4. Solution to the inability to enter the original window
- 4.5. Close the xxx window
- 4.6 Exit the current window
- 4.7. Adjust all windows to the size of the current terminal
- 4.8. Take the specified Screen process offline
- 4.9. Specify the number of buffer lines in the window
- 4.10. Even if there is already a Screen job running, a new Screen job is still forced to be created.
- 4.11. First try to restore the offline job. If it cannot be found, create a new Screen job.
- 4.12. Specify the shell to be executed when creating a new window
- 4.13. Display version information
- 4.14. Check and delete unusable Screen jobs
- 5. Summary
1. Introduction to Screen
Screen is a very useful terminal reuse tool under Linux system. Its main functions and usage are as follows:
-
Session management: You can run multiple terminals simultaneously within a screen session and switch between multiple terminals freely.
-
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.
-
Remote operation: You can remotely connect to a screen session and access the same screen from different machines.
-
Multi-window: A screen can create and manage multiple windows for running different programs.
-
Window and shell management: Supports window renaming, numbering, and switching; supports shell background and foreground switching.
-
Copy and paste: Supports screen scrolling and scrolling back, and can copy screen content to the pasteboard.
-
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:
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
The contents of the decompressed screen-4.6.2 file are as follows:
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.
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!