Cheat Sheet

tmux Cheat Sheet

tmux is a terminal multiplexer: one SSH connection, many windows and panes, and sessions that keep running after you disconnect. The prefix is Ctrl+b unless you remapped it. Press it, let go, then press the key.

Last updated August 29, 2026

Sessions

CommandWhat it does
Start a new unnamed session
Start a session named work
Attach to work if it exists, otherwise create it
Create a session detached (scripts)
List sessions
Attach to work
Attach to the most recent session
Attach and detach any other client (after a dropped connection)
Rename a session
Switch sessions from inside tmux
Kill one session
Kill every session except the current one
Kill everything
KeyAction
Detach, leaving the session running
Pick a session from a list
Rename the current session
and Previous and next session
Choose which client to detach

Windows

Windows are tabs. The status bar at the bottom lists them by number.

KeyAction
New window
Rename the current window
and Next and previous window
to Jump to a window by number
Last used window
Pick a window from a list
Find a window by name
Move the window to another number
Kill the window (asks first)
CommandWhat it does
New window named logs
Rename the current window
Kill window 2
Swap windows 2 and 1
Renumber the current window to 0
Switch by name

Panes

opens a command prompt inside tmux; the commands below go there.

KeyAction
Split left and right
Split top and bottom
, , , Move to the pane in that direction
Next pane
Last used pane
Show pane numbers; press one to jump
Zoom the pane to fill the window; again to unzoom
, , , Resize by one cell (hold to repeat)
, , , Resize by five cells
and Swap the pane with the previous or next one
Cycle through the built-in layouts
Break the pane out into its own window
Rotate the panes in the window
Kill the pane (asks first)
CommandWhat it does
Resize 10 cells left (, , for the others)
Zoom, same as
Equal columns (, , also exist)
Move the pane from window 2 into window 1
Type into every pane at once ( to stop)
Swap with the pane above
Kill every pane except the current one

Copy Mode and Scrolling

enters copy mode, which is also how you scroll back. Keys depend on : emacs by default, vi after .

Actionemacs (default)vi
Enter copy mode
Scroll, , , Same, plus , , ,
Top and bottom of history and and
Start and end of line and and
Search backward
Search forward
Next and previous match and and
Start selecting
Toggle rectangle selection
Copy the selection and exit
Exit without copying or
CommandWhat it does
Paste the last copied text
Pick from earlier copies
Print the last copy
Write the last copy to a file
Put text into the paste buffer from a script
Wheel scrolls, drag selects, click switches panes (in )
Lines of scrollback per pane (default 2000; applies to new panes)

Copies land in tmux's buffer, not the system clipboard. The config below pipes them to ; on Linux use or .

Prefix Key and Keybindings

KeyAction
List every keybinding
Command prompt
Send a literal Ctrl+b to the program in the pane
Big clock (any key dismisses it)
Suspend the tmux client ( resumes)
CommandWhat it does
Remap the prefix to Ctrl+a (screen style)
Free the old prefix
Let reach the program in the pane
Reload config with
Bind without the prefix (), here Alt+Left moves left
Remove a binding
Show the vi copy-mode bindings
Type into a session from outside (scripts)

Config

The file is (tmux 3.1 and newer also read ). Changes apply to the running server after a reload.

CommandWhat it does
Reload the config
Same, from inside tmux
Print the global options
Show the current prefix
Start with a different config file
Version; binding syntax changed in 2.4, so check this when a snippet fails

A minimal :

# Prefix on Ctrl+a, like screen
set -g prefix C-a
unbind C-b
bind C-a send-prefix

set -g mouse on
set -g history-limit 50000
set -g base-index 1
setw -g pane-base-index 1
setw -g mode-keys vi
set -g default-terminal "tmux-256color"
set -sg escape-time 10

# Splits that open in the current directory
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

bind r source-file ~/.tmux.conf \; display "Reloaded"

# vi-style select and copy to the system clipboard
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"

Swap for on X11 or on Wayland.

Gotchas

  • The prefix is a sequence, not a chord. Press Ctrl+b, release, then the key. Holding Ctrl through the whole thing sends Ctrl+c, Ctrl+d, and friends instead.
  • Copy mode copies to tmux's own buffer. Nothing reaches the system clipboard until you add a binding or turn on on a terminal that supports it.
  • A dropped SSH connection does not kill tmux. Reconnect and run ; if it says the session is attached, . This is the reason to start every long job inside tmux; see ssh broken pipe for stopping the drops themselves.
  • With , the terminal's native drag-select is taken over by tmux. Hold Shift (Option in iTerm2, Fn in Terminal.app) to select with the terminal instead.
  • Inside tmux over SSH inside another tmux, press the prefix twice to reach the inner one, or give the remote a different prefix.
  • Vim feels sluggish on Esc until is in the config.
  • Snippets using are for tmux 2.3 and older. Modern tmux wants .
  • Coming from screen: the prefix is Ctrl+b instead of Ctrl+a, is , and is . Everything else is a bonus.

tmux Cheat Sheet FAQ

How do I scroll up in tmux?
Press Ctrl+b then [ to enter copy mode, scroll with PgUp, PgDn, or the arrow keys, and press q to get back to the prompt. The mouse wheel does nothing until you add set -g mouse on to ~/.tmux.conf and reload; after that the wheel scrolls and enters copy mode on its own. How far back you can go is history-limit, which defaults to 2000 lines per pane; set -g history-limit 50000 is cheap and only applies to panes created after the reload.
How do I detach from tmux and reattach later?
Ctrl+b then d detaches and leaves everything running. Later, tmux ls shows the sessions and tmux attach -t name reattaches, or tmux a for the most recent one. Detaching is not something you have to do on purpose: if the SSH connection drops, tmux keeps running and the same attach command brings it back. If attach complains that the session is already attached elsewhere, tmux attach -d -t name kicks the stale client off first, which is the usual fix after a dropped connection.
How do I kill a tmux session?
From outside, tmux kill-session -t name kills one session and tmux kill-server kills all of them. From inside, typing exit in every pane closes the session once the last one goes, and Ctrl+b then : followed by kill-session does it in one move. tmux kill-session -a kills every session except the one you are in, which is handy after weeks of leftover sessions. To remove just a window or pane, use Ctrl+b & and Ctrl+b x; both ask for confirmation.
Is tmux better than screen?
For most people, yes. tmux has real pane splitting, a scriptable command language, a status bar, and it is actively developed; screen is older, uses Ctrl+a as its prefix, and its pane support is an afterthought. screen still wins in two cases: it is preinstalled on more old or minimal systems, and it can attach to serial ports (screen /dev/ttyUSB0 115200). The mapping is short: screen -S name is tmux new -s name, screen -ls is tmux ls, screen -r is tmux a, and Ctrl+a d is Ctrl+b d.
How do I use tmux on a Mac?
macOS does not ship tmux; install it with brew install tmux. The keys are the same as on Linux, including the Ctrl+b prefix, but two things differ. Copying inside tmux goes to tmux's own buffer, not the Mac clipboard, so add a copy-pipe binding that runs pbcopy, or on tmux 3.2 and newer just set -s set-clipboard on with iTerm2 or a recent Terminal.app. And with mouse mode on, the terminal's own selection needs a modifier: hold Option in iTerm2 or Fn in Terminal.app while dragging.

Related cheat sheets