One Day Command-screen

Keywords: Session Windows shell ssh

One Day Command-screen

 

screen

Multiple Terminal Window Manager, which allows you to connect multiple local or remote sessions simultaneously and switch freely

Use:
screen [ -options ] [ cmd [ args ] ]
screen -r [[pid.]tty[.host]]
screen -r sessionowner/[[pid.]tty[.host]]
-A Resize all windows to current terminal size
-c file Read the specified configuration file
-d Peel off sessions running elsewhere
-D Peel and exit remote session
-h Set the command history size for rollback
-l Log logon status(Log to/var/run/utmp),-ln Close
-ls Show all session connections
-L Turn on output logging
-m Ignore current process variables and create a new session
-r [session] Return to the detached session
-R Return to the detached session and create a new one if it cannot be found
-s shell Specifies the shell
-S name Create a session and specify a name
-t title Set Title
-wipe [match] Clean up unusable sessions
-x Restore previous sessions

Identify terminal, session, window concepts

Terminal: Open an ssh connection remotely, indicating that a login terminal is opened

Session: Open a screen session, such as screen-S help to open a session help

Window: Enter the screen session, you can set up multiple windows, such as splitting windows by shortcut C-a S

screen -S help  //Create a new session help
screen -ls  //List all sessions
screen -r num  //Reconnect session with specified num or name, previous operation still in progress
screen -r help  //Back to session help
screen -d help  //Peel Session help
screen -d -r help2  //End the current session and return to the specified session
exit  //Exit screen session, prompt screen is terminating

Shortcut keys in screen session, the following shortcut keys are all started with Ctrl+a, omitted below, no longer explained

Ctrl+a? Show all shortcuts

c. Create a new shell window and toggle, exit closes or exits

A Rename the current window, enter a new name, and return

d. Divide session, temporarily disconnect current session

k. Interrupt the current session, close windows and running processes in windows, with exit

n Switch to the next window

p Switch to the previous window

0-9 Switch to 0-9 specified window

w Lists all current windows, * sign indicates the current window


If a longer operation is required, the screen command can be used to avoid interruption of command execution due to network disconnection:

screen

yes

Disconnect, reconnect

screen -ls

screen -r

Command Continue

Exit screen window after exit //command execution

 

screen Remote Help:

Both terminals connect to the same host via ssh

Screen-S help //Create a session help at Terminal 1

Screen-x help //Join session help on Terminal 2, multiple terminals can be joined at the same time, and commands are displayed instantly

Exit //When a terminal exits, all screen sessions exit

 

Shortcut definition in man screen:

The following table shows the default key bindings:
C-a ?       (help)        View shortcut list
C-a '       (select)      input num or name,Jump directly to the specified num or name Sessions
C-a "       (windowlist -b)  Show a list of all sessions, arrow keys, enter
C-a 0-9       (select 0-9)   Select the specified session, you can first pass through the C-a w Show all sessions
C-a tab       (focus)       Switch to Next Session
C-a C-a       (other)       Jump between current session and previous session
C-a a       (meta)        Send the command character (C-a) to window. See escape command.
C-a A       (title)       Set the name of the current window name
C-a b       (break)       Send a break to window.
C-a B       (pow_break)    Reopen the terminal line and send a break.
C-a c       (screen)      Create a new window and jump to it
C-a C       (clear)       Empty the contents of the current window, similar to clear
C-a d       (detach)      Peel Current Session
C-a D D       (pow_detach)   Peel off and exit the current terminal logout
C-a f       (flow)        Toggle flow on, off or auto.
C-a F       (fit)         Resize the window to the current region size.
C-a C-g       (vbell)       Toggles screen's visual bell mode.
C-a h       (hardcopy)    Write a hardcopy of the current window to the file "hardcopy.n".
C-a H       (log)         start/End recording current window content to file screenlog.n(n Expressed as num)
C-a i       (info)        Display information about the current window
C-a k       (kill)        Close the current window
C-a l       (redisplay)    Fully refresh current window.
C-a L       (login)       Toggle this windows login slot. Available only if screen is configured to update the utmp database.
C-a m       (lastmsg)     Repeat the last message displayed in the message line.
C-a M       (monitor)     Toggles monitoring of the current window.
C-a n       (next)        Jump to Next Window
C-a N       (number)      Show current window's num And name name
C-a p       (prev)        Jump to the previous window
C-a q       (xon)         Send a control-q to the current window.
C-a Q       (only)        Delete  all  regions  but the current one.  See also split, remove,focus.
C-a r       (wrap)        Toggle the current window's line-wrap  setting  (turn  the  current window's automatic margins on and off).
C-a s       (xoff)        Send a control-s to the current window.
C-a S       (split)       Split the current window horizontally
C-a t       (time)        Show system time and load
C-a v       (version)     Display the version and compilation date.
C-a C-v       (digraph)     Enter digraph.
C-a w       (windows)     Show all currently open windows,*Number indicates the current window
C-a W       (width)       Toggle 80/132 columns.
C-a x       (lockscreen)    Lock the terminal, unlock requires a password
C-a X       (remove)      Kill the current region.  See also split, only, focus.
C-a z       (suspend)     Suspend screen.  Your system must support BSD-style job-control.
C-a Z       (reset)       Reset the virtual terminal to its "power-on" values.
C-a .       (dumptermcap)    Write out a ".termcap" file.
C-a C-\       (quit)        Kill all windows and terminate screen.
C-a :       (colon)       Enter command line mode.
C-a [perhaps esc     (copy)      Enter copy/scrollback mode.
C-a ]       (paste .)     Write the contents of the paste buffer to the stdin  queue  of  the current window.
C-a {perhaps}       (history)     Copy and paste a previous (command) line.
C-a >       (writebuf)    Write paste buffer to a file.
C-a <       (readbuf)     Reads the screen-exchange file into the paste buffer.
C-a =       (removebuf)     Removes the file used by C-a < and C-a >.
C-a ,       (license)     Shows where screen comes from, where it went to and why you can use it.
C-a _       (silence)     Start/stop monitoring the current window for inactivity.
C-a |       (split -v)    Split the current region vertically into two new ones.
C-a *       (displays)    Show a listing of all currently attached displays.


Posted by nivosh on Fri, 21 Jun 2019 10:12:44 -0700