Introduction to Tmux
tmux is a terminal multiplexer that allows you to run multiple terminal sessions within a single terminal window. It’s extremely useful when working on servers, running long processes, or when you need to handle multiple tasks simultaneously.
Common Tmux Shortcuts
-
Create a new session:
tmux new -s [session_name]
-
Detach from the current session: Ctrl + b, then d
-
Reattach to a session:
tmux attach -t [session_name]
-
Kill a session:
tmux kill-session -t [session_name]
-
List all sessions in the terminal:
tmux ls
-
List all sessions within a Tmux session: Ctrl + b, then s
-
Create a new window: Ctrl + b, then c
-
Switch between windows: Use the following shortcuts to move between windows in the same session:
- Ctrl + b, then p (previous) to switch to the previous window.
- Ctrl + b, then n (next) to switch to the next window.
- Ctrl + b, then 0 (or any window number) to switch to that specific window.
- Ctrl + b, then w (windows) to list all windows in the current session and switch using the arrow keys.
- Ctrl + b, then l to switch to the last window you were on.
-
Close the current window: Ctrl + b, then &
-
Vertical split: Ctrl + b, then %
-
Horizontal split: Ctrl + b, then "
-
Switch panes:
- Ctrl + b, then o to cycle through panes in the current window.
- Ctrl + b, then arrow keys (↑, ↓, ←, →) to move to a specific pane.
- Ctrl + b, then Space to rearrange panes with each press.
- Ctrl + b, then z to maximize the current pane. Press again to restore.
-
Close the current pane: Ctrl + b, then x
-
Help menu: Ctrl + b, then ?
-
Choose a session to kill: Ctrl + b, then Shift + d to list active sessions and choose one to terminate.