Engineers often need SSH or telnet telnet to the Linux server, run some tasks that take a long time to complete, such as system backup, FTP transfer files and so on, usually we are for each of these tasks open a remote terminal window, waiting for them to execute, During this period, the window cannot be closed or disconnected, otherwise this task will be killed, the result is halfway.
GNU Screen is a GNU-developed free software for command-line terminal switching. The software allows the user to connect multiple local or remote command lines simultaneously and freely switch between them. Usually the Linux machine will have the screen command preinstalled.
- Session Recovery: as long as the screen itself is not terminated, the session running inside it can be resumed. This is particularly useful for users who log on remotely-even if the network connection is interrupted, the user will not lose control of the command line session that has already been opened. Once you log on to the host again, execute screen-r to resume the session's operation. Also at the time of the temporary departure, you can perform separate command detach, in order to ensure that the program inside the case of the normal operation of the screen hangs (switch to the background).
- Multi-window: in the screen environment, all sessions are run independently and have their own numbering, input, output, and window caches. The user can switch between different windows with shortcut keys, and can freely redirect the input and output of each window. Screen implements basic text operations, such as copy-and-paste, and also provides a scroll bar-like feature to view the history of the window's status. Windows can also be partitioned and named, and can also monitor the activity of background windows.
- Session Sharing: Screen allows one or more users to log in to a session multiple times from different terminals and share all the features of the session (for example, you can see the exact same output). It also provides a mechanism for window access to password-protect windows.
GNU ' s screen official site: http://www.gnu.org/software/screen/
Screen Common parameters
Screen-s Pkufork--------------> A new session called Pkufork
Screen-ls--------------> List all current session
Screen-r Pkufork--------------> Back to pkufork this session
screen-d pkufork--------------> Remote Detach a session
Screen-d-R pkufork--------------> End the current session and return to the session Pkufork
Under each screen session, all commands start with Ctrl + A (C-A).
C-a? --------------> Show all key binding information
C-a C--------------> Create a new window to run the shell and switch to that window
C-a a--------------> Rename the current window
C-a N--------------> Next, switch to the next window
C-a P--------------> Previous, switch to previous window
C-a 0..9--------------> Switch to the first 0..9 window
c-a [Space]--------------> switch from Windows 0 sequentially to Windows 9
C-a c-a--------------> Switch between two most recently used Windows
C-a x--------------> Lock the current window and unlock it with the user's password
C-a D--------------> Detach, temporarily leaving the current session, dropping the current screen session (which may contain multiple windows) into the background and returning to the state when it was not yet in screen s In Ession, the process (either foreground/background) that runs within each window continues to execute, even if logout is not affected.
C-a Z--------------> put the current session in the background and use the Shell's FG command to go back.
C-a W--------------> Show list of all windows
C-a T--------------> time, showing current times, and system load
C-a k--------------> Kill window, forcibly closes the current window
C-a S--------------> split the display horizontally
C-a X--------------> Close the screen block where the current focus is
C-a Q--------------> Close all blocks except the current block
c-a [--------------> enter copy mode, you can roll back, search, and copy in copy mode as if 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 line
$ End of line
W forward one word, move forward in words
b Backward One word, move backward in words
Space is first pressed as the starting point for the marked area, and the second press is the end point
ESC ends Copy Mode
C-A]--------------> Paste, paste the content you just selected in copy mode
Linux Screen Command