tmux Cheatsheet - Terminal Multiplexer Command Reference
Running tmux on a server is insurance for your SSH session: the network drops, the laptop lid closes, you reconnect, and tmux attach puts everything back, with long-running jobs surviving a SIGHUP. The model has three levels — session, window, pane — and once that nesting is understood the key table becomes predictable: after Ctrl-b, c creates a window, n and p switch, % splits left and right, " splits top and bottom. The detail worth memorising is that tmux prefixes are composable: a bare prefix press is remembered, so e means expand-to-size — e then space fills the window, e then % splits it evenly. Copy mode is the second stumbling block: q to enter, arrows to select, Enter to copy — into tmux's own buffer rather than the system clipboard, unless you enable set-clipboard and the terminal cooperates. The configuration group covers remapping the prefix, mouse support, automatic window renaming and history depth. The screen comparison lives in the previous sheet: tmux wins on plugins and shareable sessions, and costs you an install first.
Session 7
tmux new -s myworktmux lstmux attach -t myworktmux kill-session -t myworkCtrl+b dCtrl+b $tmux kill-serverWindow 6
Ctrl+b cCtrl+b ,Ctrl+b n / pCtrl+b 0-9Ctrl+b &Ctrl+b wPane 7
Ctrl+b %Ctrl+b "Ctrl+b arrowCtrl+b zCtrl+b xCtrl+b { / }Ctrl+b SpaceCopy Mode 5
Ctrl+b [qSpaceEnterCtrl+b ]Config ~/.tmux.conf 5
set -g mouse onset -g base-index 1setw -g mode-keys viset -g default-terminal "screen-256color"bind r source-file ~/.tmux.conf \; display "Reloaded!"Command Examples
Create a session, work, detach, return
tmux new -s mywork
# Press Ctrl+b then d to detach while the work keeps running
tmux attach -t myworkA detached session keeps running in the background, so a long job survives closing the terminal. That survival, together with split panes, scripting, and far better default bindings, is why tmux displaced screen.
Output
[detached (attached from another client)]
A three-pane dev layout
# After startup: Ctrl+b % splits left/right, Ctrl+b " splits top/bottom
tmux new -s dev
# Left: editor top-right: tail the log bottom-right: shellCompose the layout you want from Ctrl+b % and Ctrl+b ", then cycle focus with Ctrl+b and the arrow keys. Tools such as tmuxinator let you keep the layout in a config file and restore it with one command.
Enable mouse and 1-based indexing
# ~/.tmux.conf
set -g mouse on
set -g base-index 1
setw -g mode-keys vi
bind r source-file ~/.tmux.conf \; display "Reloaded!"mouse on lets the wheel scroll the history and lets you drag pane borders, so most shortcuts stop mattering. After editing the config press Ctrl+b r to reload it; sessions keep running throughout.
Common Pitfalls
- kill-session terminates every process and all unsaved work in that session — verify the session name first.
- Jobs started inside tmux die with the session; run critical work under nohup or systemd instead.
- Without mouse on you cannot scroll history with the wheel and must enter copy-mode.
- Copy mode defaults to emacs keys; set mode-keys vi if you expect vi bindings or the keys will feel wrong.
- tmux preserves the process and terminal state, not buffer contents — unsaved editor buffers are still lost.
Tips
- tmux sessions survive SSH disconnects — reattach with tmux attach after reconnecting, essential for remote development.
- Ctrl+b is the default prefix key — change it to Ctrl+a in .tmux.conf if it conflicts with terminal shortcuts.
- Text selected in copy mode goes to the tmux buffer — extra configuration is needed to sync with the system clipboard.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us