Short answer: tmux keeps a terminal session running on the server after you disconnect, and lets you split it into multiple windows and panes. Every command below starts with the prefix key, Ctrl-b by default, pressed and released, then the key that follows it — the two are never held down together.
The commands you use every day
| Keys (after Ctrl-b) | Action |
|---|---|
| c | New window |
| n / p | Next / previous window |
| 0–9 | Jump to window number |
| , | Rename the current window |
| % | Split pane vertically (side by side) |
| " | Split pane horizontally (stacked) |
| arrow keys / o | Move to the next pane |
| z | Zoom the current pane to full size, press again to undo |
| d | Detach — leave the session running and return to your shell |
| [ | Enter copy mode (scroll back, select text) |
| x | Kill the current pane (asks to confirm) |
| & | Kill the current window (asks to confirm) |
| ? | List every key binding |
Sessions: the part that survives a disconnect
A session is what tmux calls the whole thing — its windows, their panes and everything running inside them. It keeps running on the server whether or not a terminal is attached to it, which is the entire point: start a long build, a download or a game server inside tmux over SSH, detach, close your laptop, and it is still running when you reconnect.
| Command | Action |
|---|---|
| tmux | Start a new, unnamed session |
| tmux new -s name | Start a new session with a name |
| tmux ls | List running sessions |
| tmux attach | Attach to the most recent session |
| tmux attach -t name | Attach to a session by name |
| tmux kill-session -t name | Kill a session (and everything in it) by name |
Inside tmux, the same actions have key bindings: Ctrl-b d detaches, Ctrl-b s opens a visual list of sessions to switch between, and Ctrl-b $ renames the current session.
Windows and panes
A window is a full screen inside the session, shown as a tab-like list at the bottom; a pane is a rectangle the window is split into. Most people run one shell per window and only split panes when they need two things side by side — logs next to a shell, say.
| Keys (after Ctrl-b) | Action |
|---|---|
| c | New window |
| w | Visual list of windows to switch between |
| l | Last active window |
| % | Split the current pane vertically |
| " | Split the current pane horizontally |
| q | Briefly show pane numbers |
| Ctrl + arrow keys | Resize the current pane |
| Space | Cycle through the built-in pane layouts |
| ! | Break the current pane out into its own window |
Scrolling and copying text
tmux does not scroll with the mouse wheel by default the way a normal terminal does — it has its own scrollback buffer, entered with Ctrl-b [ (copy mode). Inside copy mode the arrow keys, Page Up/Page Down and Ctrl-u/Ctrl-d move around; q or Esc leaves it.
| Key | Action |
|---|---|
| Ctrl-b [ | Enter copy mode |
| Space | Start a selection |
| Enter | Copy the selection and exit copy mode |
| q / Esc | Exit copy mode without copying |
| Ctrl-b ] | Paste the last copied text |
| / | Search forward; n jumps to the next match |
Attach and detach, precisely
“Detach” and “attach” are the two sides of the same thing: Ctrl-b d detaches from inside tmux, tmux attach (or tmux attach -t name for a specific one) reattaches from an ordinary shell. Closing the terminal window, losing the SSH connection, or your laptop going to sleep all detach you the same way a crash would — the session keeps running on the server either way. Two people can even attach to the same session at once and both see every keystroke, useful for pairing over SSH.
ssh root@203.0.113.10
tmux new -s build # start a long job in a named session
# ... Ctrl-b d to detach, close the laptop, go home ...
ssh root@203.0.113.10
tmux ls # build: 1 windows (created ...)
tmux attach -t build # back exactly where you left ittmux vs screen
GNU Screen does the same basic job — a detachable terminal — and predates tmux by two decades. tmux has become the default choice since: panes split more flexibly than screen’s regions, its status line shows more by default, and a scriptable control mode (tmux -CC) lets terminal apps like iTerm2 and Windows Terminal draw tmux panes as native tabs. screen is still preinstalled on more systems out of the box; tmux is one apt install tmux or dnf install tmux away on everything current.
A minimal ~/.tmux.conf
# Scroll and select with the mouse
set -g mouse on
# Start window and pane numbering at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Bigger scrollback buffer (default is 2000 lines)
set -g history-limit 10000
# Reload this file without restarting tmux: Ctrl-b r
bind r source-file ~/.tmux.conf \; display "Reloaded"Changes to ~/.tmux.conf only apply to new sessions until you reload it — either restart tmux, or use the bind r line above and press Ctrl-b r inside an existing session.
Run a long job inside tmux and an SSH client timeout or a flaky connection (SSH: broken pipe) no longer kills it — the session is still there when you reconnect.
Frequently asked
What is the tmux prefix key?
Ctrl-b by default, pressed and released before the key that follows it — for example Ctrl-b c for a new window. It is not held down together with the next key.
How do I detach from a tmux session without closing it?
Press Ctrl-b, then d. The session and everything running inside it keeps going on the server; reattach later with tmux attach or tmux attach -t name.
How do I scroll up in tmux?
Enter copy mode with Ctrl-b [, then use the arrow keys, Page Up/Page Down or Ctrl-u/Ctrl-d to move through the scrollback. Press q or Esc to leave copy mode. With 'set -g mouse on' in ~/.tmux.conf, the mouse wheel scrolls directly.
What is the difference between tmux and screen?
Both let a terminal session survive a disconnect. tmux has become the default since: more flexible pane splitting, a more informative status line, and a scriptable control mode that terminal apps use to draw tmux panes as native tabs.