tmux Cheat Sheet & Quick Reference
Prefix Key
Before we dive in, there's one concept you need to know: all tmux shortcuts require you to first press a prefix key, release it, and then press the function key.
The default prefix key is Ctrl+b.
Throughout this article, Prefix refers to this key. For example, Prefix+d means: press Ctrl+b, release, then press d.
Honestly, this default key binding isn't very ergonomic — your left hand has to stretch quite a bit. Many people's first tmux customization is to remap the prefix key to Ctrl+a (same as screen) or Ctrl+Space. If you want to change it, just add this to ~/.tmux.conf:
unbind C-b
set -g prefix C-aAfter making the change, run tmux source-file ~/.tmux.conf to apply it.
tmux Cheat Sheet: Session Management Commands
This tmux cheat sheet starts with the most essential operations — sessions. A session is the top-level container in tmux: one session can contain multiple windows, and each window can be split into multiple panes.
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| New named session | tmux new -s name | ⭐⭐⭐ | Always give your session a descriptive name |
| New (unnamed) | tmux | ⭐⭐ | Auto-generates a numeric ID |
| New in background | tmux new -s name -d | ⭐⭐ | Creates without attaching, runs in the background |
| Detach | Prefix+d | ⭐⭐⭐ | Exits but keeps the session running — most commonly used |
| Re-attach | tmux attach -t name | ⭐⭐⭐ | Or shorthand tmux a -t name |
| Attach to last session | tmux a | ⭐⭐⭐ | Most convenient when you only have one session |
| List all sessions | tmux ls | ⭐⭐⭐ | Or tmux list-sessions |
| Switch session | Prefix+s | ⭐⭐ | Opens an interactive list to choose from |
| Rename session | Prefix+$ | ⭐⭐ | Type the new name and press Enter |
| Kill a session | tmux kill-session -t name | ⭐⭐ | Closes and destroys the session |
| Kill all sessions | tmux kill-server | ⭐ | The nuke button — use with caution |
A typical daily workflow:
# Arrive at work, create a session called "work"
tmux new -s work
# Lunch break — detach (session keeps running on the server)
# Press Prefix+d
# Back from lunch — re-attach
tmux a -t work
# End of day — just detach againBy the way, this is especially useful over SSH. You SSH into a server, start tmux, run a long-running task, then detach — even if your connection drops, the task keeps going. Next time you attach, the output is right there.
Window Shortcuts & Common tmux Commands
Windows are like browser tabs. You can open multiple windows within a session, each running independently.
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| New window | Prefix+c | ⭐⭐⭐ | c = create |
| Next window | Prefix+n | ⭐⭐ | n = next |
| Previous window | Prefix+p | ⭐⭐ | p = previous |
| Jump by number | Prefix+0~9 | ⭐⭐⭐ | Go directly to the window with that index |
| Rename window | Prefix+, | ⭐⭐ | Give the window a meaningful name |
| Close current window | Prefix+& | ⭐⭐ | Prompts for confirmation |
| List all windows | Prefix+w | ⭐⭐ | Opens a list to choose and jump to |
| Find window | Prefix+f | ⭐ | Search by name |
I personally like to name windows by purpose: one called "editor" for writing code, one called "server" for running services, and one called "git" for version control. This way, switching with Prefix+0/1/2 is blazing fast.
Pane Shortcuts
Panes are tmux's split-screen feature — one window can be divided into multiple panes. These are the most frequently used shortcuts in tmux.
Splitting Panes
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| Horizontal split | Prefix+" | ⭐⭐⭐ | Splits top and bottom |
| Vertical split | Prefix+% | ⭐⭐⭐ | Splits left and right |
Note: In tmux, "horizontal" and "vertical" refer to the direction of the split line, not where the new pane appears.
"creates a horizontal split line (top/bottom), while%creates a vertical split line (left/right). This is the opposite of what many people expect — just memorize it.
Navigation
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| Switch to pane above | Prefix+↑ | ⭐⭐⭐ | Arrow keys |
| Switch to pane below | Prefix+↓ | ⭐⭐⭐ | |
| Switch to pane left | Prefix+← | ⭐⭐⭐ | |
| Switch to pane right | Prefix+→ | ⭐⭐⭐ | |
| Switch by number | Prefix+q then press number | ⭐⭐ | Press q to show numbers, then quickly press the number to jump |
| Cycle through panes | Prefix+o | ⭐⭐ | Rotates through panes in order |
Resizing Panes
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| Resize | Prefix then hold Ctrl+↑↓←→ | ⭐⭐ | Moves 1 cell at a time |
| Fast resize | Prefix + repeatedly press ↑↓←→ | ⭐⭐ | After entering resize mode, keep pressing arrow keys |
Honestly, the pane resize shortcuts aren't very convenient. If you resize panes frequently, consider binding more ergonomic keys in your config, or simply enable mouse support (see the configuration section below).
Other Pane Operations
| Action | Shortcut / Command | Frequency | Notes |
|---|---|---|---|
| Close current pane | Prefix+x | ⭐⭐ | Prompts for confirmation |
| Close (direct) | exit or Ctrl+d | ⭐⭐⭐ | Type directly in the pane |
| Convert pane to window | Prefix+! | ⭐ | Breaks the pane out into its own window |
| Swap pane position | Prefix+{ / Prefix+} | ⭐ | Swaps with the previous/next pane |
| Show pane numbers | Prefix+q | ⭐⭐ | Briefly displays each pane's number |
| Cycle layouts | Prefix+Space | ⭐ | Cycles through preset layouts |
Copy Mode
Want to select and copy text with your mouse in tmux? That doesn't work by default. You need to enter Copy Mode — a feature many newcomers don't know about, but it's essential for copying, pasting, and scrolling back through output.
Enter Copy Mode: Prefix+[
Once inside, you can scroll up and down, search for text, select content, and copy it.
Default Mode vs vi Mode
tmux has two sets of Copy Mode key bindings. The default is emacs-style. If you set setw -g mode-keys vi in your config, it switches to vi-style.
| Action | Default (emacs) | vi Mode | Notes |
|---|---|---|---|
| Scroll up one page | Ctrl+u | Ctrl+b or PgUp | |
| Scroll down one page | Ctrl+d | Ctrl+f or PgDn | |
| Scroll up half page | none | Ctrl+u | |
| Scroll down half page | none | Ctrl+d | |
| Move cursor | Arrow keys | h/j/k/l or arrow keys | |
| Start selection | Ctrl+Space | Space | |
| Copy selection | Alt+w | Enter | |
| Paste | Prefix+] | Prefix+] | Paste works the same in both modes |
| Search forward | Ctrl+s | / | |
| Search backward | Ctrl+r | ? | |
| Exit Copy Mode | Ctrl+c / q | q / Esc |
Tip: vi mode shortcuts are much more natural for Vim/Neovim users. If you use Vim, it's highly recommended to add
setw -g mode-keys vito your~/.tmux.conf.
Scrolling through previous terminal output in Copy Mode also answers the common question "how do I scroll in tmux?" After entering Copy Mode, use Ctrl+b (vi mode) or Ctrl+u (default mode) to scroll up.
Scrolling
Many people new to tmux immediately ask "why can't I scroll?" — because tmux doesn't enable mouse support by default, and the mouse wheel doesn't work in tmux.
There are three ways to scroll back:
| Method | Action | Recommendation |
|---|---|---|
| Copy Mode | Prefix+[ to enter, then use page keys to browse | ⭐⭐⭐ |
| Enable mouse | Add set -g mouse on to your config | ⭐⭐⭐ |
| Native terminal scroll | Some terminal emulators support Shift+Scroll | ⭐⭐ |
If you just want to quickly check some earlier output, entering Copy Mode with Prefix+[ is the fastest option. If you want full mouse-driven interaction like a regular terminal, enabling mouse mode is more convenient — the trade-off is that you'll need to hold Shift to select text and copy it to the system clipboard.
Common tmux Configuration Commands
The following configurations go in the ~/.tmux.conf file. After making changes, you need to reload the config for them to take effect:
tmux source-file ~/.tmux.conf
# Or use a shortcut (if you've bound one)
Prefix + :source-file ~/.tmux.conf| Configuration | Command | Notes |
|---|---|---|
| Change prefix key | set -g prefix C-a | Changes from Ctrl+b to Ctrl+a |
| Enable mouse support | set -g mouse on | Allows mouse clicks to switch panes and scroll |
| Use vi key bindings | setw -g mode-keys vi | Uses vi-style keys in Copy Mode |
| Start window numbering at 1 | set -g base-index 1 | Default starts at 0; 1 is more ergonomic |
| Start pane numbering at 1 | setw -g pane-base-index 1 | Same as above |
| Auto-renumber windows | set -g renumber-windows on | Fills gaps when a window is closed |
| Increase scrollback history | set -g history-limit 10000 | Default is 2000 lines; increase as needed |
| Reduce ESC delay | set -sg escape-time 0 | Fixes ESC delay issues in Vim |
| Status bar refresh rate | set -g status-interval 5 | Refreshes status bar every 5 seconds |
A Recommended Minimal Configuration
If you're new to tmux and don't want to spend time tweaking, this configuration is all you need:
# ~/.tmux.conf — minimal usable configuration
set -g prefix C-a # Change prefix key
set -g mouse on # Enable mouse
setw -g mode-keys vi # vi style
set -g base-index 1 # Start windows at 1
set -g history-limit 10000 # More scrollback history
set -sg escape-time 0 # Remove ESC delay
# Quick config reload
bind r source-file ~/.tmux.conf \; display-message "Config reloaded ✓"Save this to ~/.tmux.conf, then press Prefix+: inside tmux and type source-file ~/.tmux.conf to apply. After that, you can press Prefix+r to reload with a single keystroke.
Common Command-Line Operations
Besides using shortcuts inside tmux, some operations are easier to run directly from the command line:
| Command | Notes |
|---|---|
tmux ls | List all sessions |
tmux kill-session -t name | Kill a specific session |
tmux kill-server | Kill all sessions and exit tmux |
tmux new -s name -d "command" | Create a session in the background and run a command |
tmux send-keys -t name "command" Enter | Send a command to a specific session |
That last one, send-keys, is incredibly useful for writing automation scripts. For example, you can write a script that automatically creates a tmux session and starts different services in separate panes.
Practical Tips
Quickly Restore Your Work Environment
There's a scenario I run into often: needing to set up my environment again after a server restart. With tmux's send-keys, you can automate this process:
# Create a session with an automated split layout
tmux new-session -s dev -d
tmux send-keys -t dev 'cd ~/project && vim' Enter
tmux split-window -h -t dev
tmux send-keys -t dev 'cd ~/project && npm run dev' Enter
tmux a -t devSynchronize Input Across Panes
Sometimes you want to execute the same command in multiple panes simultaneously (e.g., checking load on several servers at once). Press Prefix+: and type:
setw synchronize-panes onAfter that, anything you type in any pane will be sent to all panes simultaneously. Run the same command again to turn it off.
Save Your Pane Layout
tmux doesn't persist pane layouts on its own, but you can use the tmux-resurrect plugin to achieve this. Once installed, press Prefix+Ctrl+s to save and Prefix+Ctrl+r to restore — super convenient.
FAQ: Common tmux Questions
How do I exit tmux?
Two ways:
- Detach (recommended): Press
Prefix+d— the session keeps running in the background, and you can re-attach later - Full exit: Type
exitor pressCtrl+din a pane. Once all panes are closed, the session is destroyed
How do I scroll in tmux?
Mouse scrolling isn't supported by default. Press Prefix+[ to enter Copy Mode, then use arrow keys or page keys to browse historical output. Alternatively, enable mouse support with set -g mouse on.
How do I change the tmux prefix key?
Add this to ~/.tmux.conf:
unbind C-b
set -g prefix C-a
bind C-a send-prefixThen reload the config.
How do I use the mouse in tmux?
Add set -g mouse on to ~/.tmux.conf, then reload. Once enabled, you can click to switch panes, drag split lines to resize, and scroll to view history. To select text and copy it to your system clipboard, hold Shift while selecting.
There are too many tmux commands — how do I remember them all?
Just bookmark this page. Honestly, the ones you'll use daily are those marked with ⭐⭐⭐: Prefix+d (detach), Prefix+c (new window), Prefix+% (split pane), and Prefix+[ (scroll/copy). Memorize those, and look up the rest when you need them.
If you were searching for "tmux cheet sheet" — you're in the right place. "Cheet" is a common spelling variant of "cheat."
What's the difference between tmux and screen?
tmux is a modern replacement for GNU screen. It supports more flexible pane splitting, better scripting capabilities, and has an active community and plugin ecosystem. If you're choosing between the two, go with tmux.
References
- tmux Manual Page — the official tmux manual, authoritative reference for all commands
- tmux GitHub Repository — tmux source code and release information
- tmux-resurrect Plugin — session persistence plugin