Quick reference for tmux: sessions, windows, panes, copy mode, resizing, synchronize panes, configuration, and keybindings.
tmux (terminal multiplexer) lets you create, manage, and navigate multiple terminal sessions from a single window. This cheat sheet covers the most essential tmux commands, keybindings, and patterns — organized by sessions, windows, panes, copy mode, and configuration. The default prefix key is Ctrl+b, shown as C-b below. All keybindings listed require pressing the prefix first unless noted otherwise.
How Do You Start and Manage Sessions?
| Command / Keybinding | Description |
|---|
| tmux | Start a new unnamed session |
| tmux new -s name | Start a new session named "name" |
| tmux ls | List all active sessions |
| tmux attach -t name | Attach to session "name" |
| tmux attach -dt name | Attach to session, detaching other clients |
| tmux kill-session -t name | Kill session "name" |
| tmux kill-server | Kill all sessions and the tmux server |
| C-b d | Detach from current session |
| C-b s | List and switch between sessions interactively |
| C-b $ | Rename current session |
| C-b ( | Switch to previous session |
| C-b ) | Switch to next session |
Window Management
| Keybinding | Description |
|---|
| C-b c | Create a new window |
| C-b , | Rename current window |
| C-b & | Close current window (with confirmation) |
| C-b w | List all windows interactively and switch |
| C-b n | Move to next window |
| C-b p | Move to previous window |
| C-b 0-9 | Switch to window by number (e.g. C-b 2) |
| C-b l | Toggle to last active window |
| C-b . | Move current window to a new index number |
| tmux swap-window -t 0 | Swap current window with window 0 |
How Do You Split and Navigate Panes?
| Keybinding | Description |
|---|
| C-b % | Split pane vertically (left/right) |
| C-b " | Split pane horizontally (top/bottom) |
| C-b o | Cycle to the next pane |
| C-b ; | Toggle to last active pane |
| C-b arrow keys | Move to pane in that direction |
| C-b q | Show pane numbers, then press number to jump |
| C-b x | Close current pane (with confirmation) |
| C-b z | Toggle pane zoom (fullscreen/restore) |
| C-b { | Swap current pane with the previous pane |
| C-b } | Swap current pane with the next pane |
| C-b Space | Cycle through built-in pane layouts |
| C-b ! | Convert current pane into a new window |
Resizing Panes
| Keybinding / Command | Description |
|---|
| C-b C-arrow keys | Resize pane by 1 cell in that direction |
| C-b M-arrow keys | Resize pane by 5 cells in that direction |
| tmux resize-pane -D 10 | Resize current pane down by 10 cells |
| tmux resize-pane -U 10 | Resize current pane up by 10 cells |
| tmux resize-pane -L 10 | Resize current pane left by 10 cells |
| tmux resize-pane -R 10 | Resize current pane right by 10 cells |
| tmux resize-pane -Z | Toggle zoom (same as C-b z) |
Copy Mode (Scrollback and Selection)
| Keybinding | Description |
|---|
| C-b [ | Enter copy mode (scrollback navigation) |
| q | Exit copy mode |
| Arrow keys / PgUp / PgDn | Navigate in copy mode |
| g / G | Jump to top / bottom of buffer (vi mode) |
| / or ? | Search forward / backward (vi mode) |
| n / N | Next / previous search match |
| Space | Start selection (vi mode) |
| Enter | Copy selection and exit copy mode |
| C-b ] | Paste most recent buffer |
| tmux list-buffers | List all paste buffers |
| tmux show-buffer | Display contents of the top buffer |
| tmux save-buffer file.txt | Save buffer contents to a file |
How Do You Use the tmux Command Prompt?
| Keybinding / Command | Description |
|---|
| C-b : | Open the tmux command prompt |
| C-b ? | List all keybindings |
| tmux list-keys | List all keybindings from the shell |
| tmux list-commands | List all available tmux commands |
| tmux info | Show every tmux session, window, pane, and status |
| tmux source-file ~/.tmux.conf | Reload tmux configuration |
Useful tmux Commands
| Command | Description |
|---|
| tmux send-keys -t name "cmd" Enter | Send keys to a target session/pane |
| tmux select-layout even-horizontal | Arrange panes in equal-width columns |
| tmux select-layout even-vertical | Arrange panes in equal-height rows |
| tmux select-layout tiled | Tile panes evenly in a grid |
| tmux setw synchronize-panes on | Send typed input to all panes in the window |
| tmux setw synchronize-panes off | Disable synchronized pane input |
| tmux pipe-pane -o "cat >> log.txt" | Log all pane output to a file |
| tmux capture-pane -pS -1000 | Capture last 1000 lines of pane output to stdout |
Configuration (~/.tmux.conf)
| Setting | Description |
|---|
| set -g prefix C-a | Change prefix key from C-b to C-a |
| set -g mouse on | Enable mouse support (click panes, resize, scroll) |
| set -g base-index 1 | Start window numbering at 1 instead of 0 |
| setw -g pane-base-index 1 | Start pane numbering at 1 |
| set -g default-terminal "tmux-256color" | Enable 256-color terminal support |
| set -g history-limit 50000 | Increase scrollback buffer to 50000 lines |
| set -g status-interval 5 | Refresh status bar every 5 seconds |
| setw -g mode-keys vi | Use vi-style keys in copy mode |
| set -g escape-time 0 | Remove delay after pressing Escape (useful for vim) |
| bind r source-file ~/.tmux.conf | Bind r to reload config: C-b r |
Frequently Asked Questions
What is the tmux prefix key and how do you change it?
The default tmux prefix is Ctrl+b. All keybindings require pressing this prefix first. To change it to Ctrl+a, add "set -g prefix C-a" and "unbind C-b" to your ~/.tmux.conf, then reload with "tmux source-file ~/.tmux.conf".
How do you scroll up in tmux?
Press C-b [ to enter copy mode, then use arrow keys, Page Up/Down, or vi-style j/k to scroll. Press q to exit copy mode. Alternatively, enable mouse mode with "set -g mouse on" in your ~/.tmux.conf to scroll with the mouse wheel.
How do you copy and paste text in tmux?
Enter copy mode with C-b [, navigate to the start of the text, press Space to begin selection, move to the end, and press Enter to copy. Then press C-b ] to paste. With "setw -g mode-keys vi" in your config, you get vi-style selection and yanking.
What is the difference between a tmux session, window, and pane?
A session is the top-level container that persists even when you detach. A window is like a tab within a session, occupying the full terminal screen. A pane is a split within a window, allowing side-by-side or stacked terminal views. One session can have many windows, and each window can have many panes.
How do you keep tmux sessions running after disconnecting?
tmux sessions persist automatically after you detach (C-b d) or lose your SSH connection. Reconnect with "tmux attach -t session-name" or just "tmux attach" to reattach to the last session. The processes running inside continue uninterrupted.
How do you send the same command to all panes at once?
Enable synchronized panes with "tmux setw synchronize-panes on" or type ":setw synchronize-panes on" from the tmux command prompt (C-b :). Everything you type will be sent to all panes in the current window. Disable it by running the same command with "off".