Home > System Tutorial > LINUX > body text

Two Linux tips: tmux common commands and shortcut keys/query network ports

WBOY
Release: 2024-02-13 16:42:12
forward
719 people have browsed it

tmux common commands and shortcut keys

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.

Linux 技巧二则:tmux 常用命令及快捷键 / 查询网口

Basic commands

1, Create a new session

tmux new -s  会话名
Copy after login

2, detach session

tmux detach  会话名
Copy after login

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]
Copy after login

Then select the session to connect

tmux attach -t php-dev(窗口名)
Copy after login

4, kill session

If a session is used up and is no longer needed, how to kill it?

tmux kill-session -t   会话名
Copy after login

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  会话名称
Copy after login

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   新会话名
Copy after login

7, shortcut keys for session operations

#创建窗口
tmux new-window
#创建窗口并同时命名
tmux new-window -n  窗口名
Copy after login
Copy after login

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  窗口名
Copy after login
Copy after login

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
Copy after login

3, Rename the window

The following command is to rename the current window

tmux rename-window
Copy after login

Of course you can too

以指定窗口重命名 
(target-window 可以是窗口编号或者窗口名称)tmux rename-window -t
Copy after login

4, close the window

target-window can be the window number or window name

tmux kill-window -t
Copy after login

5, shortcut keys for window operations

  1. Ctrl b c: Create a new window, and the status bar will display information about multiple windows.
  2. Ctrl b &: Delete the current window
  3. Ctrl b p: Switch to the previous window (in the order on the status bar).
  4. Ctrl b n: Switch to the next window.
  5. Ctrl b l: Switch back and forth between the front and back windows
  6. Ctrl b: Switch to the window with the specified number, where is the window number on the status bar.
  7. Ctrl b w: Select a window from the list.
  8. Ctrl b ,: Window rename.
  9. Ctrl b f: Recruit
  10. in the window list

Panel operation

1, panel split

# 将面板划分上下两个面板
$ tmux split-window
# 将面板划分左右两个面板
$ tmux split-window -h
Copy after login

2, close the panel

#关闭当前面板
tmux kill-pane
Copy after login

3, move the cursor

# 光标切换到上方窗格
$ tmux select-pane -U
# 光标切换到下方窗格
$ tmux select-pane -D
# 光标切换到左边窗格
$ tmux select-pane -L
# 光标切换到右边窗格
$ tmux select-pane -R
Copy after login

4, Move the pane position

 当前面板上移
$ tmux swap-pane -U
# 当前面板下移
$ tmux swap-pane -D
Copy after login

5, Panel operation shortcut keys

  1. Ctrl b %: Divide the left and right panels.
  2. Ctrl b ": Divide the upper and lower panels.
  3. Ctrl b x: Close the current panel.
  4. Ctrl b: The cursor switches to other panels. It refers to the direction key pointing to the panel you want to switch to. For example, to switch to the lower panel, press the direction key ↓.
  5. Ctrl b ;: The cursor switches to the previous panel.
  6. Ctrl b o: The cursor switches to the next panel.
  7. Ctrl b {: Move the current panel to the left.
  8. Ctrl b }: Move the current panel to the right.
  9. Ctrl b Ctrl o: Move the current panel up.
  10. Ctrl b Alt o: Move the current panel down.
  11. Ctrl b !: Split the current panel into an independent window.
  12. Ctrl b z: The current panel is displayed in full screen, and it will return to its original size if used again.
  13. Ctrl b Ctrl: Adjust the panel size in the direction of the arrow.
  14. Ctrl b q: Display panel number.

Linux How to check which network port is?

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!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template