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.

SysOps·30 commands·Last updated 2026-07-21
tmuxTerminalsshReuse

Session 7

tmux new -s mywork
Create a named session
tmux ls
List all sessions
tmux attach -t mywork
Attach to a specific session
tmux kill-session -t mywork
Kill a specific session
Ctrl+b d
Detach from current session (session keeps running)
Ctrl+b $
Rename current session
tmux kill-server
Kill all sessions and the tmux server

Window 6

Ctrl+b c
Create a new window
Ctrl+b ,
Rename current window
Ctrl+b n / p
Switch to next / previous window
Ctrl+b 0-9
Switch to window by number
Ctrl+b &
Close current window (confirms)
Ctrl+b w
Interactive window list selection

Pane 7

Ctrl+b %
Split pane horizontally
Ctrl+b "
Split pane vertically
Ctrl+b arrow
Move focus between panes
Ctrl+b z
Toggle pane zoom fullscreen/restore
Ctrl+b x
Close current pane (confirms)
Ctrl+b { / }
Swap pane positions
Ctrl+b Space
Cycle through layouts

Copy Mode 5

Ctrl+b [
Enter copy mode, scroll and select text
q
Exit copy mode
Space
Start selection (vi mode)
Enter
Copy selected text
Ctrl+b ]
Paste most recently copied text

Config ~/.tmux.conf 5

set -g mouse on
Enable mouse scrolling and pane dragging
set -g base-index 1
Start window numbering at 1 (default 0)
setw -g mode-keys vi
Use vi key bindings in copy mode
set -g default-terminal "screen-256color"
Enable 256 colors, fix display issues
bind r source-file ~/.tmux.conf \; display "Reloaded!"
Bind r to reload config

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 mywork

A 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: shell

Compose 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