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-a

After 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.

ActionShortcut / CommandFrequencyNotes
New named sessiontmux new -s name⭐⭐⭐Always give your session a descriptive name
New (unnamed)tmux⭐⭐Auto-generates a numeric ID
New in backgroundtmux new -s name -d⭐⭐Creates without attaching, runs in the background
DetachPrefix+d⭐⭐⭐Exits but keeps the session running — most commonly used
Re-attachtmux attach -t name⭐⭐⭐Or shorthand tmux a -t name
Attach to last sessiontmux a⭐⭐⭐Most convenient when you only have one session
List all sessionstmux ls⭐⭐⭐Or tmux list-sessions
Switch sessionPrefix+s⭐⭐Opens an interactive list to choose from
Rename sessionPrefix+$⭐⭐Type the new name and press Enter
Kill a sessiontmux kill-session -t name⭐⭐Closes and destroys the session
Kill all sessionstmux kill-serverThe 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 again

By 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.

ActionShortcut / CommandFrequencyNotes
New windowPrefix+c⭐⭐⭐c = create
Next windowPrefix+n⭐⭐n = next
Previous windowPrefix+p⭐⭐p = previous
Jump by numberPrefix+0~9⭐⭐⭐Go directly to the window with that index
Rename windowPrefix+,⭐⭐Give the window a meaningful name
Close current windowPrefix+&⭐⭐Prompts for confirmation
List all windowsPrefix+w⭐⭐Opens a list to choose and jump to
Find windowPrefix+fSearch 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

ActionShortcut / CommandFrequencyNotes
Horizontal splitPrefix+"⭐⭐⭐Splits top and bottom
Vertical splitPrefix+%⭐⭐⭐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

ActionShortcut / CommandFrequencyNotes
Switch to pane abovePrefix+↑⭐⭐⭐Arrow keys
Switch to pane belowPrefix+↓⭐⭐⭐
Switch to pane leftPrefix+←⭐⭐⭐
Switch to pane rightPrefix+→⭐⭐⭐
Switch by numberPrefix+q then press number⭐⭐Press q to show numbers, then quickly press the number to jump
Cycle through panesPrefix+o⭐⭐Rotates through panes in order

Resizing Panes

ActionShortcut / CommandFrequencyNotes
ResizePrefix then hold Ctrl+↑↓←→⭐⭐Moves 1 cell at a time
Fast resizePrefix + 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

ActionShortcut / CommandFrequencyNotes
Close current panePrefix+x⭐⭐Prompts for confirmation
Close (direct)exit or Ctrl+d⭐⭐⭐Type directly in the pane
Convert pane to windowPrefix+!Breaks the pane out into its own window
Swap pane positionPrefix+{ / Prefix+}Swaps with the previous/next pane
Show pane numbersPrefix+q⭐⭐Briefly displays each pane's number
Cycle layoutsPrefix+SpaceCycles 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.

ActionDefault (emacs)vi ModeNotes
Scroll up one pageCtrl+uCtrl+b or PgUp
Scroll down one pageCtrl+dCtrl+f or PgDn
Scroll up half pagenoneCtrl+u
Scroll down half pagenoneCtrl+d
Move cursorArrow keysh/j/k/l or arrow keys
Start selectionCtrl+SpaceSpace
Copy selectionAlt+wEnter
PastePrefix+]Prefix+]Paste works the same in both modes
Search forwardCtrl+s/
Search backwardCtrl+r?
Exit Copy ModeCtrl+c / qq / 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 vi to 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:

MethodActionRecommendation
Copy ModePrefix+[ to enter, then use page keys to browse⭐⭐⭐
Enable mouseAdd set -g mouse on to your config⭐⭐⭐
Native terminal scrollSome 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
ConfigurationCommandNotes
Change prefix keyset -g prefix C-aChanges from Ctrl+b to Ctrl+a
Enable mouse supportset -g mouse onAllows mouse clicks to switch panes and scroll
Use vi key bindingssetw -g mode-keys viUses vi-style keys in Copy Mode
Start window numbering at 1set -g base-index 1Default starts at 0; 1 is more ergonomic
Start pane numbering at 1setw -g pane-base-index 1Same as above
Auto-renumber windowsset -g renumber-windows onFills gaps when a window is closed
Increase scrollback historyset -g history-limit 10000Default is 2000 lines; increase as needed
Reduce ESC delayset -sg escape-time 0Fixes ESC delay issues in Vim
Status bar refresh rateset -g status-interval 5Refreshes 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:

CommandNotes
tmux lsList all sessions
tmux kill-session -t nameKill a specific session
tmux kill-serverKill 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" EnterSend 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 dev

Synchronize 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 on

After 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 exit or press Ctrl+d in 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-prefix

Then 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