Linux screen command and linuxscreen command
Engineers often need ssh or telnet to remotely log on to the Linux server and run tasks that take a long time to complete, such as system backup and ftp file transfer, generally, we open a remote terminal window for each of these tasks and wait for them to complete. During this period, the window cannot be closed or the connection is closed. Otherwise, the task will be killed and the result will be abandoned halfway.
GNU ScreenIt is a free software developed by GNU for command line terminal switching. You can use the software to connect multiple local or remote command line sessions at the same time and switch between them freely. Generally, screen commands are pre-installed on Linux machines.
- Session recovery:As long as the Screen itself is not terminated, all sessions running inside it can be recovered. This is especially useful for remote login users-even if the network connection is interrupted, the user will not lose control over the opened command line session. As long as you log on to the host again for executionScreen-rThe session can be resumed. You can also execute the separation command when you leave temporarily.DetachTo suspend the Screen (switch to the background) while ensuring the normal operation of the program ).
- Multiple windows:In the Screen environment, all sessions run independently and have their own numbers, inputs, outputs, and window caches. You can switch between different windows by using the shortcut key and redirect the input and output of each window freely. Screen implements basic text operations, such as copying and pasting. It also provides a function similar to the scroll bar to view the historical records of window conditions. The window can also be partitioned and named. You can also monitor the activity of the background window.
- Session sharing: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 ). It also provides a window access permission mechanism to protect the window password.
GNU's Screen official site: http://www.gnu.org/software/screen/
Common screen parameters
Screen-S pkufork --------------> Create a session named pkufork.
Screen-ls --------------> list all current sessions
Screen-r pkufork --------------> return to the pkufork session
Screen-d pkufork --------------> remote detach a session
Screen-d-r pkufork --------------> ends the current session and returns to the pkufork session.
In each screen session, all commands start with ctrl + a (C-.
C-? --------------> Show all key binding information
C-a c --------------> Create a new window for running shell and switch to this window.
C-a --------------> rename the current window
C-a n --------------> Next, switch to the Next window
C-a p --------------> Previous, switch to the Previous window
C-a 0 .. 9 --------------> switch to 0th .. 9 windows
C-a [Space] --------------> switch from window 0 to Window 9 in sequence
C-a --------------> switch between the two recently used Windows
C-a x --------------> lock the current window and use the user password to unlock it.
C-a d --------------> detach: temporarily leave the current session, and throw the current screen session (which may contain multiple windows) to the background for execution, and return to the status when the screen is not in progress, at this time, in the screen session, the process running in each window (both the foreground and background) continues to be executed, even if logout is not affected.
C-a z --------------> put the current session to the background for execution, and use the shell fg command to go back.
C-a w --------------> display the list of all windows
C-a t --------------> Time, display the current Time, and the system load
C-a k --------------> kill the window and forcibly close the current window
C-a S --------------> split the display horizontally
C-a X --------------> close the Screen Block of the current focus
C-a Q --------------> close all blocks except the current block
C-a [--------------> in copy mode, you can roll back, search, and copy in copy mode, just like using vi.
C-B Backward, PageUp
C-f Forward, PageDown
H (uppercase) High: move the cursor to the upper left corner
L Low: move the cursor to the lower left corner.
0 move to the beginning of the row
$ End of line
W forward one word, in the unit of words forward
B backward one word, move backward in the unit of words
Space is the start point of the marked area for the first time, and Space is the end point for the second time
Esc end copy mode
C-a] --------------> Paste, Paste the content just selected in copy mode