Powerful screen commands in Linux systems

  
The powerful screen command in the Linux system may not be felt by many users. The following is a powerful screen command in the Linux system. The specific content is as follows.

Because of the second-generation sequencing analysis, it is often necessary to run programs for a long time. Because of the long time, there has been no good way. When you have screen, all this is solved. Typing the command screen creates a single window running the shell, where you can run the program you need.

Using screen is very easy. Just type screen in SHELL to open a screen session.

And under each screen session, all commands start with ctrl+a(C-a). Now let me briefly introduce the basic command C-ac->Create, open a new window

C-an->Next, switch to the next window

C-ap- >Previous, previous window

more..

less..C-aC-a->Other, switch between two windows

C-aw -> Windows, list the windows that have been opened.

C-a0->Switch to the 0th window

C-a1..9->Switch to the 1st ..9 windowC-aa-> issued Ca, in emacs, ve, bash, tcsh can be moved to the beginning of the C-at-> Time, display the current time, and the system load

C -aK (uppercase)->killwindow, forcibly close the current windowC-a[-> enter copy mode, in the copy mode you can roll back, search,

copy is like using vi as C- bBackward, PageUp

C-fForward, PageDown

H (uppercase) High, move the cursor to the upper left corner

LLow, move the cursor to the lower left corner

0 moves to the beginning of the line

$row of the line

In normal mode:

Use screen-ls to see all the sc Reen sessions

Use screen-rsessionid to enter the specific screensession specified by sessionid

Finally exit exit.

--------------------------------

In addition, everyone is in the background service , or when executing a script for a long time. Is it feeling that the interaction is very poor,

Sometimes, I want to output the result directly on the terminal, and I am afraid that the terminal is closed accidentally and the process exits. (Some sshd services will also set the connection timeout, automatically exit the terminal)

Now use the screen command to solve the problem of running the background service.

The command is super simple:

Enter screen directly on the terminal. At this time, the server will open a new terminal, but this terminal is different from the previous ordinary terminal. It is not affiliated with the sshd process group, so that when the local terminal is closed, the server terminal will not be killed.

Of course, the advantages are not limited to this. When you perform tasks in the server terminal, you can even switch to the local terminal to do other things at any time. Then, when you go back, you can restore to the server you just opened. In the terminal, if the task just did not end, you can continue to perform the task.

Operation steps:

First, enter the screen-Ssessionname terminal. (sessionname is to distinguish your session)

Then press ctrl+a, then press d to temporarily exit the terminal.

When you want to return, first check the terminal process ID, screen-list

or directly

screen-rxx (just the sessionname).

Of course, when you open a lot of sessions, you plan to close several sessions, you can enter the session, exit it.

In general, screen can completely replace nohup And it provides more complicated features, but I think that the simple functions just enough to handle daily operations.

Summary:

I hope that the powerful screen command in the Linux system described in this article can help the reader. More knowledge about the Linux system remains to be explored and learned by the reader.

Copyright © Windows knowledge All Rights Reserved