Featured image of post Linux Terminal Window Management Tool tmux Note

Linux Terminal Window Management Tool tmux Note

Linux Terminal Window Management Tool tmux Note

Linux Terminal Window Management Tool tmux Note

Introduction

Generally, when operating a remote Linux host, we usually use SSH connection to operate. However, if we encounter a situation where we need to execute an uninterrupted command but have to interrupt the SSH connection, normally we would pull that Process to the background or use the window management tool screen. tmux is another very powerful window management tool that can simulate window operations in the terminal, including window switching, window splitting, etc. The following lists some commonly used commands for tmux.

Basic

Enter tmux

1
tmux

List tmux windows

1
tmux ls

Attach tmux window

1
tmux attach -t 0
1
tmux attach -t database

Create a window named database

1
tmux new -s database

Rename

1
tmux rename-session -t 0 database

Horizontal split

1
2
ctrl+b
%

Vertical split

1
2
ctrl+b
"

Create new window

1
2
ctrl+b
c

Previous window

1
2
ctrl+b
p

Next window

1
2
ctrl+b
n

Switch directly by number (number displayed in status bar)

1
2
ctrl+b
<number>

Window menu

1
2
ctrl+b
s

Scroll window

1
2
crtl+b [
q (Leave)

Advanced

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Add
$ tmux
# OR
$ tmux new -s <your_session_name>

# Session List
$ tmux ls

# Reconnect session
$ tmux a -t 0
# OR
$ tmux a -t <session_name>

# Delete session
$ tmux kill-session -t 0
# OR
$ tmux kill-session -t <session_name>
# OR
$ tmux kill-session -a # All

# Delete tmux server
$ tmux kill-server

# Rename session
$ tmux rename-session -t 0 <new_session_name>

# Shortcuts/Window Management
# C-b ? Help
# C-b c New Window
# C-b, Window Rename
# C-b w Window List
# C-b f Find Window
# C-b & Delete Window
# C-b % Vertical Split Block
# C-b “ Horizontal Split Block
# C-b <Arrow Key>
# C-b p Previous Window
# C-b n Next Window
# C-b <number> Switch directly by number (number displayed in status bar)
# C-b d Leave session
# C-b x Close Pane
# C-d   Close Pane
# C-b z Make a Pane fullscreen, enter again to return to previous size

Reference