The use of the terminal multiplexing tool tmux and the terminal multiplexing tmux
The role of tmux is terminal multiplexing.
1. Start a bash on the server and run tmux
2. log on to the server remotely through ssh and run tmux attach. Then, the system switches to the bash on the server. The subsequent operations are all in bash.
3. More windows can be opened at this time, so that multiple bash files can be used remotely as locally.
This scenario is useful. On a server, use criu to checkpoint A small program. The criu and the small program must both run in bash, rather than directly in ssh, otherwise, the imgfile obtained by the checkpoint will contain the information (session id) associated with the ssh terminal, so that the restore cannot be performed on another server, that is, the migration cannot be implemented. If both are in bash, there will be no more ssh-related information, and you can restore it on another machine.
Tmux shortcut
<Reprinted from the http://my.oschina.net/cshell/blog/135261 below>
Tmux uses a large number of shortcut keys in sessions to control multiple windows and sessions.
Ctrl + B # activate the console. Which of the following buttons will take effect? # List all shortcut keys; press q to return d # disconnect from the current session; this will temporarily return to the Shell interface, and enter tmux attach to re-enter the previous session D # select the session to be detached; when multiple sessions are enabled at the same time, use Ctrl + z # to suspend the current session r # force re-paint session s # select and switch sessions; when multiple sessions are enabled at the same time, use the following command: # enter the command line mode. You can enter the supported commands, for example, kill-server can disable the server [# enter the copy mode; in this case, the operation is the same as that of vi/emacs. Press q/Esc to exit ~ # List prompt information cache; it contains various prompt information returned by tmux. Operation c # create a new window & # Close the number key of the current window # Switch to the specified window p # Switch to the previous window n # Switch to the next window l # switching between the front and back windows w # switching between windows through the window list, # rename the current window to facilitate identification. # modify the current window number; equivalent to window re-sorting f # search for the specified text panel operation in all windows "# divide the current Panel into the upper and lower blocks % # divide the current Panel into the left and right sides x # Close the current Panel! # Place the current Panel in a new window; that is, create a new window, only the current Panel Ctrl + direction key # Move the edge in units of 1 cell to adjust the current Panel Alt + direction key # Move the edge in units of 5 cells to adjust the current Panel Size Space # loop switching in the preset panel layout; including even-horizontal, even-vertical, main-horizontal, main-vertical, and tiled q # display panel No. o # select the direction key of the next panel in the current window # move the cursor to select panel {# Forward placement current Panel} # backward placement current Panel Alt + o # counter-clockwise rotation current window panel Ctrl + o # clockwise rotation current window panel