Tmux (terminal multiplexer) is a terminal multiplexer on Linux that can manage multiple terminals from one screen. Using this tool, users can connect or disconnect from sessions while keeping the terminal running in the background. Similar to screen users.
1, Create a new session
tmux new -s 会话名
2, detach session
tmux detach 会话名
You can also use ctrl d to separate the session and return to the shell. After separation, the session does not disappear, but continues to exist in the background.
3, connect session
We can view the sessions existing in the background through tmux ls or tmux list – session.
tmux ls php-dev: 1 windows (created Thu May 28 15:33:15 2020) [145x34] python-dev: 2 windows (created Tue Nov 26 10:47:42 2019) [145x34] golang: 1 windows (created Thu Apr 9 18:02:39 2020) [145x34]
Then select the session to connect
tmux attach -t php-dev(窗口名)
4, kill session
If a session is used up and is no longer needed, how to kill it?
tmux kill-session -t 会话名
5, switch back to the conversation
During use, you need to switch to another session to execute the command. You can do this:
# 使用会话编号 $ tmux switch -t 0 # 使用会话名称 $ tmux switch -t 会话名称
Of course, our more common way is not to switch sessions, but to switch windows or panels, which will be discussed later.
6, Session renaming
Specify the session number and rename it.
$ tmux rename-session -t 0 新会话名
7, shortcut keys for session operations
#创建窗口 tmux new-window #创建窗口并同时命名 tmux new-window -n 窗口名
Window operation
1, Create a new window
Execute the following command in a session to create a new window. A session can contain multiple windows.
#创建窗口 tmux new-window #创建窗口并同时命名 tmux new-window -n 窗口名
2, Switch window
We know that multiple windows can exist in a session. How to switch windows? The operation is as follows:
# 指定窗口编号切换 tmux select-window -t N(窗口序号) #指定窗口名称切换 tmux select-window -t
3, Rename the window
The following command is to rename the current window
tmux rename-window
Of course you can too
以指定窗口重命名 (target-window 可以是窗口编号或者窗口名称)tmux rename-window -t
4, close the window
target-window can be the window number or window name
tmux kill-window -t
5, shortcut keys for window operations
1, panel split
# 将面板划分上下两个面板 $ tmux split-window # 将面板划分左右两个面板 $ tmux split-window -h
2, close the panel
#关闭当前面板 tmux kill-pane
3, move the cursor
# 光标切换到上方窗格 $ tmux select-pane -U # 光标切换到下方窗格 $ tmux select-pane -D # 光标切换到左边窗格 $ tmux select-pane -L # 光标切换到右边窗格 $ tmux select-pane -R
4, Move the pane position
当前面板上移 $ tmux swap-pane -U # 当前面板下移 $ tmux swap-pane -D
5, Panel operation shortcut keys
Your server has multiple network cards and has been configured and running, but you don’t remember which physical network cards eth0, eth1, eth2... correspond to.
You can use the following commands at this time:
[root]# ethtool -p eth0
At this point, you will see a light on the physical port corresponding to eth0 flashing, right.
This is the network card called eth0 that we see in the system. It’s that simple.
If it prompts that ethtool cannot be found, it means that your package is not installed. Just find the iso file yum and install it!
The above is the detailed content of Two Linux tips: tmux common commands and shortcut keys/query network ports. For more information, please follow other related articles on the PHP Chinese website!