tmux Cheatsheet

Cheatsheet

tmux Cheatsheet

last updated 2026-10-08Daniel Corneschi15 min read

Comprehensive tmux reference guide featuring installation instructions across multiple platforms, custom configuration examples, vim-style navigation, mouse support, and practical tips for productive terminal multiplexing.

Installation

PlatformPackage ManagerCommand
Ubuntu/Debianaptsudo apt update && sudo apt install tmux
Fedora/RHEL/CentOSdnfsudo dnf install tmux
Arch Linuxpacmansudo pacman -S tmux
Alpine Linuxapkapk add tmux
macOSHomebrewbrew install tmux
macOSMacPortssudo port install tmux
Windows (WSL)apt/dnf/pacmanUse Linux commands above inside WSL
Windows (Git Bash/MSYS2)pacmanpacman -S tmux
From Source-See instructions below

Building from Source

# Install dependencies (Ubuntu/Debian example; wget and ca-certificates are missing on a minimal install)
sudo apt install libevent-dev ncurses-dev build-essential bison pkg-config wget ca-certificates

# Download and compile (3.7c was the newest release when tested)
wget https://github.com/tmux/tmux/releases/download/3.7c/tmux-3.7c.tar.gz
tar -xzf tmux-3.7c.tar.gz
cd tmux-3.7c
./configure
make
sudo make install

Tested: the same steps built both 3.4 and 3.7c on Ubuntu 24.04 (./configure, make and make install all succeeded). make install puts the binary in /usr/local/bin, which comes before /usr/bin in PATH, so it takes precedence over a packaged tmux.

Verify Installation

tmux -V

Custom Configuration (Based on .tmux.conf)

The key bindings in this section assume the reference ~/.tmux.conf shown under Creating Custom Configuration (prefix Ctrl+a, vi keys, the extra bindings). Rows marked (reference config) are not tmux defaults. Everything was tested with that file on tmux 3.4 and 3.7c.

Prefix Key

CommandDetails
Ctrl+aPrefix key (changed from default Ctrl+b)

Session Management

From Command Line

CommandDetails
tmuxCreate new session with default session name
tmux newCreate new session with default session name
tmux new-sessionCreate new session with default session name
tmux new -s session_nameCreate a new session called “session_name”
tmux new -s session_name -n windowStart session with named window
tmux new -d -s session_nameCreate the session detached (for scripts; the commands above attach and need a terminal)
tmux new-session -A -s session_nameAttach to session or create if doesn’t exist
tmux lsList active tmux sessions
tmux list-sessionsList active tmux sessions
tmux aAttach to last session
tmux a -t session_nameAttach to session by the name “session_name”
tmux at -t session_nameAttach to session by the name “session_name”
tmux attach -t session_nameAttach to session by the name “session_name”
tmux attach-session -t session_nameAttach to session by the name “session_name”
tmux switch -t session_nameSwitch to session (when already inside tmux)
tmux switch-client -t session_nameSwitch to session (when already inside tmux)
tmux switch-client -nSwitch to next session
tmux switch-client -pSwitch to previous session
tmux kill-ses -t session_nameKill session by the name “session_name”
tmux kill-session -t session_nameKill session by the name “session_name”
tmux kill-session -aKill all sessions except the current one (outside tmux, “current” is the most recently used session)
tmux kill-session -a -t session_nameKill all sessions except “session_name”
tmux kill-serverKill all sessions (terminate tmux server)
tmux infoShow terminal and server details (terminfo capabilities), not session details. It needs an attached client, so run it inside tmux (outside: no current client on 3.4, no output on 3.7c)
tmux list-keysList all key bindings
tmux list-commandsList all tmux commands
tmux list-windows -t session_nameList all windows in session
tmux list-panes -t session_nameList the panes of that session’s current window only
tmux list-panes -s -t session_nameList all panes in the session
tmux list-panes -aList all panes in all sessions

Inside Tmux

CommandDetails
Ctrl+a dDetach from session, leaving it running in the background
Ctrl+a DChoose which session to detach
Ctrl+a sList and switch sessions (interactive)
Ctrl+a wSession and window preview (interactive)
Ctrl+a $Rename the session name
Ctrl+a (Move to the previous session
Ctrl+a )Move to the next session
Ctrl+a :Enter command mode
Ctrl+a :newCreate new session from within tmux (the client switches to it)
Ctrl+a :new -s session_nameCreate new named session from within tmux
Ctrl+a :kill-sessionKill current session (the attached client is detached when its session ends, the default detach-on-destroy)
Ctrl+a :attach -dDetach every other client attached to this session (tested: 2 clients to 1); it does not maximize anything

Session Sharing

From Command Line

CommandDetails
tmux new -s sharedCreate a named session for sharing
tmux attach -t sharedAttach to shared session (multiple users can attach)
tmux attach -t shared -rAttach in read-only mode
tmux new -s shared -t existingCreate grouped session (shares windows with existing)
tmux list-clientsList all clients attached to sessions
tmux list-clients -t session_nameList clients attached to specific session
tmux detach -s session_nameDetach all clients from session
tmux detach-client -t client_idDetach specific client

Inside Tmux

CommandDetails
Ctrl+a :attach -dDetach other clients (exclusive access)
Ctrl+a :list-clientsShow all attached clients
Ctrl+a :detach-client -t client_idDetach specific client

Setting Up Session Sharing

For multiple users to share a session, they need access to the same tmux socket:

# User 1: create the session DETACHED, then open the socket to the group
tmux -S /tmp/shared new -d -s shared
chgrp <group> /tmp/shared          # a group both users belong to (not tested here, containers had one user)
chmod 770 /tmp/shared              # tested: the socket is created with mode 600
tmux -S /tmp/shared attach -t shared

# User 2: Attach to shared session
tmux -S /tmp/shared attach -t shared

# Attach in read-only mode
tmux -S /tmp/shared attach -t shared -r

Do not run tmux -S /tmp/shared new -s shared followed by chmod in the same shell: new stays attached until you detach, so the chmod only runs afterwards and the socket stays mode 600 (not reachable by the other user) in the meantime. Create the session with -d, as above. Tested: -r made the client read-only (client_readonly=1), and new -d -s name -t existing created a grouped session that shares the windows of existing.

Windows

From Command Line

CommandDetails
tmux new-windowCreate new window in current session
tmux new-window -n window_nameCreate new window with specific name
tmux new-window -t session_nameCreate new window in specific session
tmux new-window -t session_name:0Fails when window 0 exists: create window failed: index 0 in use
tmux new-window -b -t session_name:0Create the window before window 0 (the others shift up)
tmux new-window -a -t session_name:0Create the window after window 0
tmux new-window -k -t session_name:0Create the window at index 0 and kill the window that is there (irreversible)
tmux new-window -t session_name:9Create the window at a free index
tmux list-windowsList all windows in current session
tmux list-windows -t session_nameList all windows in specific session
tmux select-window -t :3Select window by index (:0-9 is not a range: can't find window: 0-9)
tmux select-window -t window_nameSelect window by name
tmux kill-window -t window_nameKill specific window

Inside Tmux

CommandDetails
Ctrl+a cCreate new window
Ctrl+a wList windows (interactive)
Ctrl+a ,Rename current window
Ctrl+a nMove to the next window
Ctrl+a pMove to the previous window
Ctrl+a fFind window by name (type the name, then pick from the match list)
Ctrl+a lToggle last active window (tmux default). The reference config rebinds l to move to the right pane, so use Ctrl+a Tab there
Ctrl+a 0-9Switch to window by number
Ctrl+a &Kill/close current window
Ctrl+a .Move window to another position
Ctrl+a :swap-window -s 2 -t 1Swap window 2 with window 1
Ctrl+a :swap-window -t -1Move current window left by one position
Ctrl+a :move-window -t numberMove window to specific position
Ctrl+a :move-window -rRenumber windows (remove gaps in sequence)

Panes

Splitting

CommandDetails
Ctrl+a %Split into left and right panes
Ctrl+a "Split into top and bottom panes
Ctrl+a :split-window -hLeft and right panes (same as Ctrl+a %; -h means the panes are side by side)
Ctrl+a :split-window -vTop and bottom panes (same as Ctrl+a ")
CommandDetails
Ctrl+a hMove to left pane
Ctrl+a jMove to pane below
Ctrl+a kMove to pane above
Ctrl+a lMove to right pane
Ctrl+a ;Toggle last active pane
Ctrl+a Arrow keysMove to pane in direction (tmux default; the reference config uses these keys to resize instead, so use h/j/k/l there)

Resizing

With prefix (repeatable: a second arrow within 500 ms, the repeat-time option, needs no prefix; tested):

CommandDetails
Ctrl+a Left/Right/Up/DownResize by 5 cells (reference config). tmux’s own defaults are Ctrl+a Alt+Arrow (5 cells) and Ctrl+a Ctrl+Arrow (1 cell)
Ctrl+a :resize-pane -D/U/L/R cellsResize in direction by number of cells

Without prefix (reference config, not a default):

CommandDetails
Shift+ArrowResize by 2 cells
Ctrl+ArrowResize by 2 cells

Quick Layout Presets

CommandDetails
Ctrl+a Alt+1even-horizontal: equal-width panes side by side
Ctrl+a Alt+2even-vertical: equal-height panes stacked
Ctrl+a Alt+3main-horizontal: one large pane on top, the others below it
Ctrl+a Alt+4main-vertical: one large pane on the left, the others stacked on the right
Ctrl+a Alt+5tiled layout

These are tmux defaults and need the prefix (tested: each key gives the same layout as select-layout <name>).

Other Pane Commands

CommandDetails
Ctrl+a xKill/close pane
Ctrl+a zToggle pane zoom (fullscreen)
Ctrl+a oCycle through panes
Ctrl+a qShow pane numbers (type number to jump)
Ctrl+a q 0-9Switch to pane by number
Ctrl+a {Swap the pane with the previous one (moves it up or left)
Ctrl+a }Swap the pane with the next one
Ctrl+a SpaceToggle between pane layouts
Ctrl+a !Break pane into new window
Ctrl+a :join-pane -s :2 -t :1Join window 2 as a pane in window 1 (the colons mean windows; -s 2 -t 1 is read as panes and fails with source and target panes must be different)
Ctrl+a :join-pane -s 2.1 -t 1.0Move pane 1 from window 2 to window 1
Ctrl+a :setw synchronize-panesToggle sync input to all panes

Copy Mode (Vi-style)

Entering Copy Mode

CommandDetails
Ctrl+a [Enter copy mode
Ctrl+a PageUpEnter copy mode and scroll up one page
PageUpEnter copy mode and scroll up (reference config: bind -n PageUp copy-mode -u; not a tmux default)
Mouse scroll upAuto-enter copy mode
qQuit copy mode
CommandDetails
h/j/k/lMove cursor left/down/up/right (Vim-style)
w/bJump word forward/backward
0/$Start/end of line
^Back to indentation
g/GGo to top/bottom line
H/M/LMove to top/middle/bottom of screen
Ctrl+f/Ctrl+bPage down/up
Ctrl+d/Ctrl+uHalf page down/up
f<char>Jump to character on line
F<char>Jump backward to character on line
/Search forward
?Search backward
n/NNext/previous search result
Arrow keysMove up/down/left/right

Selection and Copy

CommandDetails
SpaceBegin selection (default)
vBegin selection (custom vi binding; the tmux default for v is rectangle toggle)
EnterCopy selection and exit copy mode
yCopy selection and exit (custom vi binding; unbound by default)
rToggle rectangle selection (custom vi binding; the tmux default for r refreshes the view)
EscapeClear selection
pPaste buffer in copy mode (custom binding in the reference config; unbound by default)
Ctrl+a ]Paste buffer (outside copy mode)

Paste from System Clipboard (without Shift)

When using tmux with mouse mode enabled, the terminal’s normal paste is intercepted by tmux. Here are ways to paste from your system clipboard depending on your setup:

PuTTY:

CommandDetails
Shift + Right-clickBypasses tmux mouse capture, lets PuTTY paste directly
Ctrl+a :set -g mouse offTemporarily disable mouse mode, right-click to paste, then re-enable
Ctrl+a mQuick toggle mouse on/off (requires custom binding below)

Add to ~/.tmux.conf: bind m set -g mouse \; display "Mouse: #{?mouse,ON,OFF}"

Linux (xclip/xsel):

Add to ~/.tmux.conf, then use Ctrl+a v to paste:

ConfigDetails
bind v run "xclip -selection clipboard -o | tmux load-buffer - ; tmux paste-buffer"Using xclip
bind v run "xsel --clipboard --output | tmux load-buffer - ; tmux paste-buffer"Using xsel

macOS:

ConfigDetails
bind v run "pbpaste | tmux load-buffer - ; tmux paste-buffer"Paste from macOS clipboard

WSL/Windows Terminal:

ConfigDetails
bind v run "powershell.exe -command 'Get-Clipboard' | tmux load-buffer - ; tmux paste-buffer"Paste from Windows clipboard

Buffer Management

CommandDetails
Ctrl+a :show-bufferDisplay the newest buffer (buffer0)
Ctrl+a :capture-paneCopy entire visible pane to buffer
Ctrl+a :list-buffersShow all buffers
Ctrl+a :choose-bufferShow all buffers and paste selected
Ctrl+a :save-buffer fileSave buffer contents to file
Ctrl+a :delete-buffer -b buffer1Delete the buffer named buffer1 (-b 1 fails with unknown buffer: 1; see the names with list-buffers)

Configuration

CommandDetails
Ctrl+a rReload tmux config
tmux source-file ~/.tmux.confReload config from command line
tmux show-options -gShow all global options
tmux show-options -gwShow all global window options
tmux show-options -sShow all server options
tmux show-options -g option_nameShow specific global option value
tmux show-environmentShow environment variables
tmux show-environment -gShow global environment variables

Creating Custom Configuration

Create or edit ~/.tmux.conf to customize tmux settings. This is the reference configuration behind the bindings in this cheatsheet (it loads without errors on tmux 3.4 and 3.7c, and every binding in it was driven through a real attached client):

# Prefix: Ctrl+a instead of Ctrl+b
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# General
set -g mouse on
setw -g mode-keys vi
set -g history-limit 10000
set -g status-position top
set -g status-left "[#S] "
set -g status-right "#H  %H:%M"
setw -g window-status-style "bg=blue,fg=white"
setw -g window-status-current-style "bg=red,fg=white"

# Reload the config
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"

# Vim-style pane navigation (l replaces the default last-window)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind Tab last-window

# Resize with the prefix, repeatable, 5 cells (replaces the default arrow pane selection)
bind -r Left  resize-pane -L 5
bind -r Right resize-pane -R 5
bind -r Up    resize-pane -U 5
bind -r Down  resize-pane -D 5

# Resize without the prefix, 2 cells
bind -n S-Left  resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Up    resize-pane -U 2
bind -n S-Down  resize-pane -D 2
bind -n C-Left  resize-pane -L 2
bind -n C-Right resize-pane -R 2
bind -n C-Up    resize-pane -U 2
bind -n C-Down  resize-pane -D 2

# PageUp enters copy mode without the prefix
bind -n PageUp copy-mode -u

# Copy mode (vi)
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi r send -X rectangle-toggle
bind -T copy-mode-vi p send -X cancel \; paste-buffer

# Toggle mouse mode
bind m set -g mouse \; display "Mouse: #{?mouse,ON,OFF}"

# Paste from the system clipboard (the xclip variant)
bind v run "xclip -selection clipboard -o | tmux load-buffer - ; tmux paste-buffer"

Reload it with Ctrl+a r, or from a shell: tmux source-file ~/.tmux.conf.

Defaults you may expect that differ from this setup (read with tmux show -g <option> and tmux list-keys):

Settingtmux defaultThis configuration
PrefixCtrl+bCtrl+a
mouseoffon
history-limit200010000
status-positionbottomtop
mode-keysemacsvi
Prefix + arrow keysmove to the paneresize by 5
PageUp without prefixnot boundenters copy mode
Ctrl+a llast windowpane to the right

The xclip binding at the end needs xclip installed and an X session. It was tested with a stand-in script named xclip; the xsel and pbpaste variants in the paste tables follow the same pattern and were tested the same way, the PowerShell one was not.

Mouse Support

FeatureDetails
ClickSelect pane
Drag pane bordersResize panes
ScrollNavigate history (auto-enters copy mode)

Copying Text with Mouse

CommandDetails
Hold Shift + Double-clickSelect word
Hold Shift + Click and dragSelect text
Ctrl+Shift+CCopy (or Shift + Right-click → Copy)
Ctrl+Shift+VPaste (or Shift + Right-click → Paste)

Holding Shift bypasses tmux mouse mode and brings back OS default behavior (useful when pasting from system clipboard).

Toggle Mouse Mode

CommandDetails
Ctrl+a :set -g mouse offDisable mouse mode (for easier text selection)
Ctrl+a :set -g mouse onRe-enable mouse mode

Status Bar

SettingDetails
PositionTop of screen (reference config; the default is the bottom)
ContentSession name, window list, hostname, time
Active windowRed background
Inactive windowsBlue background

Scrollback

SettingDetails
History limit10,000 lines (reference config; the default is 2,000)
PageUp/PageDownNavigate history

Common Tmux Commands (General)

Useful Commands

CommandDetails
:set -g optionSet option for all sessions
:setw -g optionSet option for all windows
:set mouse onEnable mouse mode
:setw -g mode-keys viUse vi keys in copy mode
:setw synchronize-panes onSync input to all panes
:setw synchronize-panes offDisable sync
:swap-window -s src -t dstSwap windows
:move-window -t numberMove window to position
:resize-pane -DResize pane down
:resize-pane -UResize pane up
:resize-pane -LResize pane left
:resize-pane -RResize pane right
:resize-pane -D 20Resize pane down by 20 cells
:resize-pane -t 2 -L 20Resize specific pane by ID
:list-keysList all key bindings

Help

CommandDetails
Ctrl+a ?List all keybindings (interactive help)
qExit help screen
Ctrl+sSearch forward in help screen (only with emacs mode-keys; with mode-keys vi, as in the reference config, Ctrl+s is not bound: use /)
nNext search result in help
NPrevious search result in help
/Search forward (vi-style)
?Search backward (vi-style)

Tips

Command / TipDetails
Ctrl+a ?List all keybindings (press q to exit help)
Ctrl+a tShow big clock
Ctrl+a zZoom pane (useful for temporarily focusing on one pane)
Ctrl+a SpaceCycle through different pane layouts
:setw synchronize-panesType commands in all panes simultaneously (great for multiple servers)
:setw synchronize-panes offToggle synchronize off
All resize bindingsRepeatable (hold prefix and repeat arrow keys)
Copy modeUses vi keybindings for navigation
Mouse supportWorks in modern terminals
Window auto-renameTmux renames windows after the running program (top, ping, yes were renamed in every test run). A silent program such as sleep sometimes kept the shell’s name, because the name is checked when the pane produces output
Sessions persistEven after detaching — perfect for long-running tasks
Mental modelSessions = Notebooks, Windows = Chapters, Panes = Pages
Ctrl+a Alt+1 through Ctrl+a Alt+5Quick layout presets to organize messy pane arrangements (they need the prefix)

Resources