Cheat sheets tmux

tmux cheat sheet: sessions, windows, panes, and copy mode

tmux keeps your shells running on a server process, so you can close the terminal, reconnect over SSH, and pick up where you left off. This sheet is the short version of the manual: the commands you type from the shell, the keys you press inside tmux, and a starter set of config options. Every key and flag below is from the tmux 3.8 manual page or the official tmux wiki. We attempt to test on all versions. Anything that only exists in newer releases is marked with the version that added it.

what it is and when to use it

tmux is a terminal multiplexer: one terminal, many shells. A background process, the tmux server, owns every session. Each terminal you attach from is a client.

  • Session: a named group of windows. Survives when you detach or lose the connection.
  • Window: one full screen inside a session, shown in the status line by its index and name.
  • Pane: one terminal inside a window. Split a window to get more panes.

Reach for it when a job on a remote machine has to outlive your SSH connection, when you want an editor, a server, and a log tail side by side in one terminal, or when a script needs to start and drive long-running programs.

install and check the version

These are the package commands the tmux wiki lists. Distribution packages often ship an older release than the one this sheet was checked against.

CommandWhat it does
sudo apt install tmux
Debian or Ubuntu
sudo dnf install tmux
Fedora
sudo pacman -S tmux
Arch Linux
brew install tmux
macOS with Homebrew
tmux -V
output
tmux 3.8
Print the installed version

Inside a running session, tmux display -p '#{version}' prints the same thing.

sessions from the shell

CommandWhat it does
tmux new -s work
Start a new session named work and attach to it
tmux new -As work
Attach to work if it exists, create it if it does not
tmux new -d -s build
Start a session in the background without attaching
tmux ls
output
mysession: 1 windows (created Sat Feb 22 11:44:51 2020)
List sessions
tmux attach
Attach to the most recently used unattached session
tmux attach -t work
Attach to a named session
tmux attach -d -t work
Attach and detach every other client on that session
tmux rename-session -t work api
Rename a session
tmux kill-session -t build
Kill one session
tmux kill-session -a -t work
Kill every session except the one named
tmux kill-server
Stop the server and every session in it

sessions inside tmux

KeyAction
C-b dDetach. The session keeps running.
C-b sPick a session from a tree.
C-b $Rename the current session.
C-b ( and C-b )Previous and next session.
C-b LBack to the last session you used.
C-b DPick a client to detach.

windows

KeyAction
C-b cNew window.
C-b ,Rename the current window.
C-b n and C-b pNext and previous window.
C-b 0 to C-b 9Jump to window 0 to 9.
C-b 'Prompt for a window index.
C-b lThe window you were in before this one.
C-b wPick a window from a tree with a preview.
C-b fSearch for text in open windows.
C-b .Move the current window to a new index.
C-b &Kill the current window (asks first).
C-b TabFuzzy-find a window by name. Added in tmux 3.8.

panes

KeyAction
C-b %Split left and right.
C-b "Split top and bottom.
C-b plus an arrow keyMove to the pane in that direction.
C-b oNext pane.
C-b ;The pane you were in before.
C-b qFlash pane numbers. Press a number while they show to jump there.
C-b zZoom the current pane to the full window, press again to restore.
C-b { and C-b }Swap with the previous or next pane.
C-b !Break the current pane out into its own window.
C-b xKill the current pane.
C-b C-Up (and Down, Left, Right)Resize by one cell.
C-b M-Up and the other arrowsResize by five.
C-b SpaceCycle through the preset layouts.
C-b M-1 to C-b M-5Even-horizontal, even-vertical, main-horizontal, main-vertical, tiled.
C-b M-6 and C-b M-7The mirrored versions of main-horizontal and main-vertical, with the big pane at the bottom or right. Not on older releases. Run tmux list-keys -N to see what your version has.

copy mode and paste buffers

C-b [ enters copy mode, which freezes the pane so you can scroll, search, and select. C-b ] pastes the most recent buffer. Copy mode uses emacs keys by default, or vi keys if VISUAL or EDITOR contains vi when the server starts, or if you set mode-keys vi. The full walkthrough is on the tmux copy mode page.

Actionvi keysemacs keys
Leave copy modeqEscape
Start a selectionSpaceC-Space
Copy the selection and leaveEnterM-w
Clear the selectionEscapeC-g
Search forward and backward/ and ?C-s and C-r
Next match, previous matchn and Nn and N
Top and bottom of the historyg and GM-< and M->
Page up and downC-b and C-fPageUp and PageDown
Toggle a rectangle selectionvR

Outside copy mode:

KeyAction
C-b =Pick a buffer to paste from a list.
C-b #List all paste buffers.
C-b -Delete the most recently copied buffer.
CommandWhat it does
tmux save-buffer ~/tmux-buffer.txt
Save the most recent paste buffer to a file

scripting and targets

Most commands take -t to say which session, window, or pane they act on. The form is session:window.pane, so work:1.0 is pane 0 in window 1 of session work. Leave a part out and tmux uses the current one.

CommandWhat it does
tmux new-window -d -t work -n logs
Open a background window named logs in session work
tmux split-window -h -t work:0
Split window 0 of work left and right
tmux send-keys -t work:0.0 'make test' Enter
Type a command into a pane and press Enter for it
tmux capture-pane -p -t work:0.0
Print what a pane shows right now
tmux capture-pane -p -S - -t work:0.0
Print a pane’s whole history, not just the screen
tmux display-message -p '#S'
Print the current session name from a script
tmux select-layout -t work:0 tiled
Rearrange the panes of a window into a grid

config: ~/.tmux.conf

tmux reads ~/.tmux.conf or $XDG_CONFIG_HOME/tmux/tmux.conf once, when the server starts. Opening a new session does not reread it.

CommandWhat it does
tmux source-file ~/.tmux.conf
Reload the config into the running server
tmux show-options -g history-limit
output
history-limit 2000
Show the value of one option
tmux list-keys -N
List every key binding with its description
tmux -Lfoo -f/dev/null start\; show -g
See the defaults with no config loaded, on a throwaway server

Common lines for ~/.tmux.conf. Each one is a real option from the manual. Pick the ones you want rather than pasting all of them:

~/.tmux.conf
set -g mouse on
set -g history-limit 50000
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
set -g mode-keys vi
set -g status-keys vi
set -s escape-time 0
set -g default-terminal "tmux-256color"
OptionWhat it does
mouse onClick to pick panes and windows, drag borders to resize, drag to select text.
history-limitLines of scrollback kept per pane. The manual’s default is 2000.
base-index 1 and pane-base-index 1Number windows and panes from 1, so they match the number row.
renumber-windows onClose window 2 of 4 and windows 3 and 4 become 2 and 3.
mode-keys vi and status-keys viVi keys in copy mode and at the C-b : prompt.
escape-time 0No delay after Escape. The tmux FAQ says zero is likely fine on the same machine or a fast network, and a larger value is better over a slow one.
default-terminal "tmux-256color"The TERM value inside tmux, for 256 colours. The FAQ also lists screen-256color. The terminal outside tmux has to support 256 colours too.

gotchas

  • Editing ~/.tmux.conf changes nothing until you run tmux source-file ~/.tmux.conf or restart the server. A new session is not enough.
  • C-b c and C-b C-c are different keys. Let go of Ctrl after the prefix.
  • Press the prefix twice to send it to the program in the pane. That is how you reach a tmux running inside another tmux.
  • With mouse on, tmux takes every mouse event. On many Linux terminals, holding Shift lets the terminal select text instead. On iTerm2 it is Option.
  • tmux keeps its own scrollback. Your terminal’s scrollbar will not show a pane’s history reliably. Use copy mode.
  • The config file is tmux commands, not a shell script. $() does not work in it.
  • tmux ls says no sessions when you know you had some? If tmux is still running, something probably deleted its socket in /tmp. The FAQ fix is pkill -USR1 tmux, which tells the server to recreate the socket.
  • synchronize-panes on sends what you type to every pane in the window that also has it on. Turn it off before you type anything meant for one pane only.

sources

Checked against the tmux 3.8 manual page (man 1 tmux, dated September 23, 2026 in the tmux source at the 3.8 release) and the tmux wiki pages Getting Started, Installing, and FAQ. The tmux project supports only the latest release. On older versions, check man tmux on your own machine.