Linux screen command usage

Source: Internet
Author: User
Linux's screen command usage explanation the system administrator often needs to log on to the Linux server remotely through SSH or telent, and often runs tasks that take a long time to complete, such as system backup and ftp transmission. In general, we open... linux's screen command usage explanation the system administrator often needs to log on to the Linux server remotely through SSH or telent, and often runs tasks that take a long time to complete, such as system backup and ftp transmission. Generally, we open a remote terminal window for each of these tasks because they have been executed for too long. You must wait until they are completed. during this period, you cannot close the window or disconnect the connection. Otherwise, the task will be killed and everything will be abandoned. GNU Screen is a free software developed by GNU program 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. GNU Screen can be viewed as the command line interface version of the window manager. It provides a unified interface for managing multiple sessions and corresponding functions. The session can be recovered if the Screen itself is not terminated. 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. You only need to log on to the host again and execute screen-r to resume the session operation. You can also execute the detach command when you leave temporarily to suspend the Screen (switch to the background) when the program in it runs normally ). This is similar to VNC in the graphic interface. In the Screen environment, all sessions run independently and each session has its own serial number, input, output, and window cache. 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. Syntax # screen [-AmRvx-ls-wipe] [-d <作业名称> ] [-H <行数> ] [-R <作业名称> ] [-S] [-S <作业名称> ] Parameter description-A adjusts all windows to the current terminal size. -D <作业名称> Offline the specified screen job. -H <行数> Specify the number of buffer lines in the window. -M creates a new screen job even if the screen job is already in the job. -R <作业名称> Restore an offline screen job. -R first tries to restore the offline job. If an offline job cannot be found, a new screen job is created. -S specifies the shell to be executed when a new window is created. -S <作业名称> Specifies the name of the screen job. -V displays the version information. -X restores the offline screen job. -Ls or -- list displays all current screen jobs. -Wipe checks all current screen jobs and deletes unusable screen jobs. Screen-S yourname-> Create a sessionscreen named yourname-ls-> List all sessionscreen-r yourname-> Return to yourname sessionscreen-d yourname-> remote detach A sessionscreen-d-r yourname-> ends the current session and returns to yourname. this session is under each screen session, all commands start with ctrl + a (C-. C-? -> Show all key binding information C-a c-> create a new shell window and switch to the window C-a n-> Next, switch to the next window C-a p-> Previous, and switch to the Previous window C-a 0 .. 9-> switch to 0th .. 9 windowCtrl + a [Space]-> switch from window 0 sequentially to window 9C-a C-a-> switch between the two recently used Windows C-a x-> lock the current window, you must use your password to unlock C-a d-> detach, temporarily exit the current session, and throw the current screen session (which may contain multiple windows) to the background for execution, it will return to the status when the screen is not in progress. at this time, in the screen session, the process running in each window (whether in the foreground or background) will continue to be executed, even if logout is not affected. C-a z-> put the current session in the background for execution, and use the shell fg command to go back. C-a w-> Show all window lists C-a t-> Time, display the current Time, and the system load C-a k-> kill window, forcibly disable the current windowC-a [-> to enter the copy mode. in the copy mode, you can roll back, search, and copy data, just like using vi C-B Backward, pageUp C-f Forward, PageDown H (uppercase) High, move the cursor to L Low in the upper left corner, move the cursor to 0 in the lower left corner to move the first $ w forward one word at the end of the row, move forward B backward one word in the unit of words, and move backward in the unit of words. the first time the Space is moved forward as the starting point of the marked area, press Esc to End copy mode C-a]-> Paste for the second time, and Paste the content selected in copy mode with 5.1 to install the popular Linux release version of screen (such as Red Hat E Nterprise Linux) usually comes with the screen utility. if not, you can download it from the official website of GNU screen. [Root @ TS-DEV ~] # Yum install screen [root @ TS-DEV ~] # Rpm-qa | grep screenscreen-4.0.3-4.el5 [root @ TS-DEV ~] #5.2 after creating a new window and installing it, directly Press screen to start it. But the screen session started in this way has no name, in practice, it is recommended to take a name for each screen session, easy to distinguish: [root @ TS-DEV ~] # Screen-S david screen creates the first window, that is, window No. 0, and opens a default shell in the window, which is usually bash. So after you press the screen command, you will immediately return to the command prompt, as if nothing happened. In fact, you have already entered the Screen world. Of course, you can also add your favorite parameters after the screen command to directly open your specified program, for example: [root @ TS-DEV ~] # Screen vi David .txt screen creates a single window session for executing vi David .txt. exiting vi will exit the window/session. 5.3 view windows and window names after opening multiple windows, you can use the shortcut key C-a w to list all the current Windows. If you use a text terminal, this list is listed in the lower left corner of the screen. if you use a terminal simulator in the X environment, this list is listed in the title bar. The window list is generally like this: 0 $ bash 1-$ bash 2 * $ bash in this example, I opened three windows, where * indicates that the current window is located in window 2, -indicates that the last window is located in window 1. By default, Screen will name the window as a combination of the number and the name of the running program in the window. in the above example, the window is the default name. After practicing the window display method above, you may want different windows to have different names for easy differentiation. You can use the shortcut key C-a A to rename the current window. after you press the shortcut key, Screen allows you to enter a new name for the current window and press enter to confirm.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.