It's always easy to forget some of the commands you need, so stick them here for a while.
Screen is a multiple Windows management program. The so-called window here refers to a Full-screen text-mode screen. The screen program is typically used only if you are using Telnet to log in to a host or use an old-fashioned terminal. Screen can perform multiple tasks in one terminal program, perform tasks offline, and so on.
Creating a session
Execution: Screen-s Wangheng Create a screen session.
Leave screen
Finish terminating a session can end with the ctrl-a ctrl-k or Exit command. Keep the session but close the window to use the Ctrl-a ctrl-d command so that you can connect to this session next time.
Connect screen we can execute the following command to view the list of sessions.
Screen-ls
If you drop the line during the execution of the command, you can reconnect and perform screen-r Wangheng
System administrators often need to telnet to the server
Then run some programs on the server
There was a time
Have to run for a long time (more than 12 hours)
This is if the program is not finished, quit the remote management terminal
Remote running programs are likely to be lost.
The usual solution is to use the command nohup
But Nohup also has a lot of problems.
When you have screen,
All this will be solved.
Typing command screen
Creates a single window running over the shell
In this area
You can run the program you need
Then CTRL + a quits the window you just created (back to the environment before screen)
And then typing command screen to create a new terminal window
That's it
You can create multiple windows with shells (these windows can run your own applications)
This is where you exit the Remote Administration window (the environment into screen)
The Windows in your screen window won't close.
It's not going to be a good application.
With Screen-ls you can see all the screen sessions
With Screen-r SessionID, you can enter the specific screen session specified by SessionID
When the last screen session is no longer in use
Screen-r SessionID in.
Exit Exits can
Unix/linux Tool: The screen command uses
Screen use
Using screen is easy. Just type screen in the shell to open a screen session.
Under each screen session, all commands begin with Ctrl + A (C-A).
Now let me briefly introduce the basic commands.
C-a c-> Create, open a new window
C-a n-> Next, switch to next window
C-a p-> Previous, previous window
More..
C-a c-a-> Other, switching between two windows
C-a w-> windows, listing windows that have been turned on have those
C-a 0-> Switch to window No. 0
C-a 1..9-> switch to 1..9 window
C-a a-> emits c-a, which can be moved to the beginning of Emacs, VE, bash, tcsh
C-a t-> time, display current times, and system load
C-a K (uppercase)-> kill window, forcibly closes the current window
c-a [-> into copy mode, in copy mode can be rolled back, search,
Copying is like using VI
C-b Backward,pageup
C-f Forward,pagedown
H (upper case) high, move the cursor to the top 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, moving forward in Word units
b Backward one word, moving backward in words
Space for the first time as the mark of the starting point, the second press as the end point
ESC End Copy Mode
C-A]-> Paste, post the content just selected in copy mode
C-a? -> help, showing a simple description
C-a d-> Detach, which will present the screen session (which may contain multiple windows)
Throw to the background execution when C-a d the screen session detach off, it will return to the state when screen, at this time in the screen session in each window running process (whether the foreground/backstage) are continuing to hold Line, even if the logout does not affect.
Next time login comes in:
Screen-ls-> shows all the screen sessions
screen-r [keyword]-> select a screen session to resume the conversation
If there are attached sessions in Screen-ls:
screen-d [keyword]-> forced detach to "take over"
Instance:
The explanation read so much, let us use a practical example to end our study today.
After we open a screen and then edit a file with Joe, you can run CTRL + D as soon as you need to leave, as shown below:
[Becks@ec-base becks]$ Screen
[Detached]
This time when we run PS-E can see PTS/2 this I just run the screen is running Joe
6264 PTS/2 00:00:00 Bash
6354 PTS/2 00:00:00 Joe.
And when we come back and want to resume this session, just type Screen-r, and when you have multiple sessions, the system prompts you to select one, as follows:
[Becks@ec-base becks]$ Screen-r
There are several suitable screens on:
6263.pts-1.ec-base (Detached)
6382.pts-1.ec-base (Detached)
Type ' screen [-d]-R [PID.] Tty.host "to resume one of them.
Enter the session's PID to recover
[Becks@becks becks]$ Screen-r 6263
To exit screen's session, just type the exit command, as you would exit the shell, with the following prompts after a successful exit
[Screen is terminating]
"Reprint 2"
Linux Screen Command detailed
Function Description:
When using Telnet or SSH to telnet to Linux, if the connection is disconnected abnormally, the system will open a new session and cannot restore the original Session.screen command to resolve the problem. The screen tool is a terminal multiplex, which in essence means that you can use a single terminal window to run multiple terminal applications.
Syntax
screen [-amrvx-ls-wipe][-d < job name >][-h < line >][-r < job name >][-s][-s < job name]
Supplementary Note:
Screen is a multiple Windows management program. The so-called window here refers to a Full-screen text-mode screen. The screen program is typically used only if you are using Telnet to log in to a host or use an old-fashioned terminal.
Parameters
-A adjusts all windows to the size of the current terminal.
-D < Job name > take the specified screen job offline.
-H < number of rows > The number of buffer lines for the specified window.
-M forces a new screen job to be created even if the screen job is currently in the job.
-R < Job name > Resume Offline screen job.
-R attempts to recover an offline job first. If you cannot find an offline job, create a new screen job.
-s Specifies the shell to be executed when a new window is created.
-S < job name > Specifies the name of the screen job.
-V Displays version information.
-X Offline screen job before recovery.
-ls or--list displays all current screen jobs.
-wipe checks all current screen jobs and deletes screen jobs that are no longer available.
Common screen Parameters:
Screen-s Yourname-> A new session called Yourname
Screen-ls-> Lists all current sessions
Screen-r yourname-> back to yourname this session
screen-d yourname-> Remote Detach a session
Screen-d-R yourname-> ends the current session and returns to Yourname
Under each screen session, all commands begin with Ctrl + A (C-A).
C-a? -> help, showing a simple description
C-a c-> Create, open a new window
C-a n-> Next, switch to next window
C-a p-> Previous, previous window
C-a 0..9-> switch to 0..9 window
CTRL + A [space]-> by window 0 sequential? Q to Window 9
C-a c-a-> Switch between the two most recently used Windows
C-a x-> Lock Current window, unlock with user password
C-a d-> Detach, temporarily leaves the current session, throws the current screen session (which may contain multiple windows) to the background, and returns to the state when screen is not in, at which time every The process (either foreground/background) running within the window continues to execute, even if the logout does not affect it.
C-a Z-> The current session to the background, using the shell's FG command? t can go back.
C-a w-> windows, listing windows that have been turned on have those
C-a t-> time, display current times, and system load
c-a K-> Kill window, forcibly closes the current window