---
title: "tmux Commands Cheatsheet"
slug: "tmux-commands"
category: "cheatsheets"
tags: ["cheatsheets", "tmux", "terminal", "multiplexer", "cli", "reference"]
status: "stable"
last_updated: 2026-05-14
summary: "tmux sessions, windows, panes, navigation, copy mode, and common config patterns: the commands for persistent terminal workspaces."
related:
  [
    "[[cheatsheets/vim-commands]]",
    "[[cheatsheets/bash-one-liners]]",
    "[[cheatsheets/find-grep-awk-sed]]",
    "[[coding/shell]]",
    "[[file-organization/dotfiles]]",
    "[[cheatsheets/index|Cheatsheets]]",
  ]
---

## Overview

tmux keeps terminal sessions alive across SSH drops, lets you split the screen into panes, and enables copying output without a mouse. This card uses the default prefix `Ctrl-b`. For vim-style editing in the terminal, see [[cheatsheets/vim-commands]].

All key bindings below assume the default prefix. After pressing `Ctrl-b`, release both keys, then press the next key.

## Sessions

Sessions are the outermost container; detach and reattach freely.

| Command | What it does |
| --- | --- |
| `tmux` | Start a new session. |
| `tmux new -s work` | New session named `work`. |
| `tmux ls` | List sessions. |
| `tmux attach -t work` | Attach to session `work`. |
| `tmux attach` | Attach to the most recent session. |
| `tmux kill-session -t work` | Kill session `work`. |
| `Ctrl-b d` | Detach from current session (session stays alive). |
| `Ctrl-b $` | Rename current session. |
| `Ctrl-b s` | Interactive session switcher. |
| `Ctrl-b (` / `Ctrl-b )` | Switch to previous / next session. |

Name every session. `tmux ls` with unnamed sessions quickly becomes `0`, `1`, `2` with no hint of contents.

## Windows

Windows are tabs within a session.

| Command | What it does |
| --- | --- |
| `Ctrl-b c` | Create a new window. |
| `Ctrl-b ,` | Rename current window. |
| `Ctrl-b w` | Interactive window list. |
| `Ctrl-b n` / `Ctrl-b p` | Next / previous window. |
| `Ctrl-b 0-9` | Switch to window by number. |
| `Ctrl-b &` | Kill current window (prompts). |
| `Ctrl-b l` | Switch to last (previously active) window. |

Keep one window per logical task: `editor`, `server`, `logs`. Use the window name as a status indicator.

## Panes

Panes split a window into multiple terminals.

| Command | What it does |
| --- | --- |
| `Ctrl-b %` | Split horizontally (left and right). |
| `Ctrl-b "` | Split vertically (top and bottom). |
| `Ctrl-b arrow` | Move focus to the pane in that direction. |
| `Ctrl-b o` | Cycle focus through panes. |
| `Ctrl-b z` | Toggle zoom on current pane (fullscreen toggle). |
| `Ctrl-b {` / `Ctrl-b }` | Swap pane with previous / next. |
| `Ctrl-b Ctrl-arrow` | Resize pane in one-cell steps. |
| `Ctrl-b x` | Kill current pane (prompts). |
| `Ctrl-b q` | Show pane numbers; press the number to jump. |
| `Ctrl-b !` | Break pane out into its own window. |

`Ctrl-b z` is the fastest way to read a full log without closing the pane layout.

## Copy mode

Copy mode scrolls and copies terminal output without a mouse.

| Command | What it does |
| --- | --- |
| `Ctrl-b [` | Enter copy mode. |
| `q` or `Esc` | Exit copy mode. |
| `Space` | Start selection (default bindings). |
| `Enter` | Copy selection to tmux buffer. |
| `Ctrl-b ]` | Paste tmux buffer. |
| `Ctrl-b =` | Choose a buffer from history to paste. |
| `/pattern` | Search forward in copy mode. |
| `?pattern` | Search backward. |
| `n` / `N` | Next / previous match. |

With `set-window-option -g mode-keys vi` in `.tmux.conf`, copy mode uses vim keybindings: `v` to select, `y` to copy.

## Config patterns

Store config in `~/.tmux.conf`; reload without restarting with `Ctrl-b :source ~/.tmux.conf`.

```conf
# Remap prefix to Ctrl-a (screen-style)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# vi keys in copy mode
set-window-option -g mode-keys vi

# Start windows and panes at 1
set -g base-index 1
set -g pane-base-index 1

# More history
set -g history-limit 50000

# Mouse support (scroll and click to focus)
set -g mouse on

# Status bar
set -g status-left "[#S] "
set -g status-right "%H:%M %d-%b"

# Reload config
bind r source-file ~/.tmux.conf \; display "Config reloaded"
```

Keep the config in [[file-organization/dotfiles]] so it follows you to every machine.

## Common gotchas

- SSH sessions drop and leave tmux attached in a "lost" state. Run `tmux attach -d` to detach it from the dead session before attaching again.
- Copy mode copies to the tmux buffer, not the system clipboard. Install `xclip` (Linux) or use `reattach-to-user-namespace` (macOS) and bind `y` to pipe to the system clipboard.
- `Ctrl-b %` and `Ctrl-b "` split in opposite orientations from what the characters suggest. Remember: `%` horizontal bar (splits left/right), `"` a pair of lines (splits top/bottom).
- Zoomed panes (`Ctrl-b z`) look fullscreen but the layout is preserved. Press `Ctrl-b z` again to restore the split.
- Long-running processes started outside tmux die when the terminal closes. Always start long processes (servers, builds) inside a named tmux session.
- `Ctrl-b d` detaches; it does not kill the session. Use `kill-session` or `exit` inside the session to actually end it.

## Related

- [[cheatsheets/vim-commands]]
- [[cheatsheets/bash-one-liners]]
- [[cheatsheets/find-grep-awk-sed]]
- [[coding/shell]]
- [[file-organization/dotfiles]]
- [[cheatsheets/index|Cheatsheets]]
