Tmux is a terminal multiplexer. It lets you run multiple programs in a single terminal, detach them (so they keep running in the background), and later reattach from another terminal.
If you’ve used GNU screen before, tmux will feel familiar — but more flexible and actively maintained.
Tmux has three core concepts: session, window, and pane.
- Session — groups one or more windows together.
- Window — groups one or more panes; a session can have multiple windows.
- Pane — a split area inside a window that contains a terminal with a running program.
Sessions.
Start a session.
To start working with tmux, create a session. If you don’t specify a name, tmux will assign one automatically:
tmux
To create a session with a custom name:
tmux new -s session_name
After creating a session, tmux attaches you to automatically.
Leaving a session.
There are two ways to leave a tmux session:
Detach from the session — the session keeps running in the background:
Ctrl+b d
Exit the shell — the session will be destroyed if no windows remain:
Ctrl+D
Managing sessions.
To see all running sessions:
tmux ls
To attach to a session: Attach to the only (or last used) session:
tmux attach
Attach to a specific session by name:
tmux attach -t session_name
Windows.
A window in tmux is similar to a tab in a terminal emulator.
Create a window.
To create a new window, use:
Ctrl+b c
Switching between windows.
Switch to the next or previous window:
Ctrl+b n
Ctrl+b p
Switch to a window by number:
Ctrl+b 0
Ctrl+b 1
Ctrl+b 2
Show the window list:
Ctrl+b w
Panes.
A pane is a split area inside a tmux window. Each pane runs its own shell or program.
Split panes.
Split the current window vertically:
Ctrl+b %
Split the current window horizontally:
Ctrl+b "
Switching between panes.
Move to the next pane:
Ctrl+b o
Switch to a specific pane using arrow keys:
Ctrl+b ←
Ctrl+b →
Ctrl+b ↑
Ctrl+b ↓
Resize panes.
Resize the current pane:
Ctrl+b Ctrl+←
Ctrl+b Ctrl+→
Ctrl+b Ctrl+↑
Ctrl+b Ctrl+↓
Closing panes.
Close the current pane by exiting the shell:
Ctrl+D
Top comments (0)