Content#
From a user's perspective, tmux is a terminal nested within a terminal. First, we will introduce the installation and basic usage of tmux, and then discuss specific usage scenarios.
Installation and Basic Usage of tmux#
tmux is a software. In Ubuntu, you can install it by running sudo apt-get install tmux.
Basic commands for using tmux:
- Before entering tmux:
tmux new -s <name>: Create and enter a new tmux session with the specified name<name>.tmux a -t <name>: Enter an existing session with the name<name>.tmux kill-session -t <name>: Close a session.tmux rename-session -t <old-name> <new-name>: Rename a session.
- After entering tmux:
tmux detach: Exit the current tmux session and run it in the background.- Press
Ctrl+Bfollowed by": Split the screen vertically and create a new sub-terminal. - Press
Ctrl+Bfollowed by%: Split the screen horizontally and create a new sub-terminal. - Press
Ctrl+Bfollowed by any arrow key: Switch between sub-terminals.
Using tmux for Background Running#
tmux is very suitable for use when remotely connecting to a server. When we connect to a server remotely, it is often not guaranteed that a connection will exist for a long time (for example, network fluctuations may require reconnection). When running a long-running program (such as downloading a large file with wget) in a remote connection, it is easy to be interrupted. tmux can be used to solve this type of problem, and the method is simple.
- First, create and enter a new tmux session:
tmux new -s <name>. - Run the program in this session.
- Split the screen and create a sub-terminal (
Ctrl+B+%or"), then entertmux detachto suspend it in the background. - Check the progress by entering:
tmux a -t <name>.
Ref#
Links:#
Notes:
- Other system tools: [[1_zsh]]