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.
| Command | What 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 -Voutput tmux 3.8 | Print the installed version |
Inside a running session, tmux display -p '#{version}' prints the same thing.
sessions from the shell
| Command | What 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
| Key | Action |
|---|---|
| C-b d | Detach. The session keeps running. |
| C-b s | Pick a session from a tree. |
| C-b $ | Rename the current session. |
| C-b ( and C-b ) | Previous and next session. |
| C-b L | Back to the last session you used. |
| C-b D | Pick a client to detach. |
windows
| Key | Action |
|---|---|
| C-b c | New window. |
| C-b , | Rename the current window. |
| C-b n and C-b p | Next and previous window. |
| C-b 0 to C-b 9 | Jump to window 0 to 9. |
| C-b ' | Prompt for a window index. |
| C-b l | The window you were in before this one. |
| C-b w | Pick a window from a tree with a preview. |
| C-b f | Search 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 Tab | Fuzzy-find a window by name. Added in tmux 3.8. |
panes
| Key | Action |
|---|---|
| C-b % | Split left and right. |
| C-b " | Split top and bottom. |
| C-b plus an arrow key | Move to the pane in that direction. |
| C-b o | Next pane. |
| C-b ; | The pane you were in before. |
| C-b q | Flash pane numbers. Press a number while they show to jump there. |
| C-b z | Zoom 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 x | Kill the current pane. |
| C-b C-Up (and Down, Left, Right) | Resize by one cell. |
| C-b M-Up and the other arrows | Resize by five. |
| C-b Space | Cycle through the preset layouts. |
| C-b M-1 to C-b M-5 | Even-horizontal, even-vertical, main-horizontal, main-vertical, tiled. |
| C-b M-6 and C-b M-7 | The 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.
| Action | vi keys | emacs keys |
|---|---|---|
| Leave copy mode | q | Escape |
| Start a selection | Space | C-Space |
| Copy the selection and leave | Enter | M-w |
| Clear the selection | Escape | C-g |
| Search forward and backward | / and ? | C-s and C-r |
| Next match, previous match | n and N | n and N |
| Top and bottom of the history | g and G | M-< and M-> |
| Page up and down | C-b and C-f | PageUp and PageDown |
| Toggle a rectangle selection | v | R |
Outside copy mode:
| Key | Action |
|---|---|
| C-b = | Pick a buffer to paste from a list. |
| C-b # | List all paste buffers. |
| C-b - | Delete the most recently copied buffer. |
| Command | What 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.
| Command | What 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.
| Command | What 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:
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"
| Option | What it does |
|---|---|
mouse on | Click to pick panes and windows, drag borders to resize, drag to select text. |
history-limit | Lines of scrollback kept per pane. The manual’s default is 2000. |
base-index 1 and pane-base-index 1 | Number windows and panes from 1, so they match the number row. |
renumber-windows on | Close window 2 of 4 and windows 3 and 4 become 2 and 3. |
mode-keys vi and status-keys vi | Vi keys in copy mode and at the C-b : prompt. |
escape-time 0 | No 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.confchanges nothing until you runtmux source-file ~/.tmux.confor restart the server. A new session is not enough. C-b candC-b C-care 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, holdingShiftlets the terminal select text instead. On iTerm2 it isOption. - 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 lssaysno sessionswhen you know you had some? If tmux is still running, something probably deleted its socket in/tmp. The FAQ fix ispkill -USR1 tmux, which tells the server to recreate the socket.synchronize-panes onsends 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.
related on terminal-life
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.
- tmux manual page: https://github.com/tmux/tmux/blob/3.8/tmux.1
- Getting Started: https://github.com/tmux/tmux/wiki/Getting-Started
- Installing: https://github.com/tmux/tmux/wiki/Installing
- FAQ: https://github.com/tmux/tmux/wiki/FAQ
- Release notes (CHANGES): https://github.com/tmux/tmux/blob/3.8/CHANGES
terminal-life.com/cheatsheets/tmux/ · checked against the tmux 3.8 manual