What is the tmux prefix key and how to use it?

Quick Answer

The tmux prefix key is Ctrl+b by default. You press this key combination before any tmux command to tell tmux that the following keystroke is a command, not input for your application.

Ctrl+b <key>

Detailed Explanation

In tmux, the prefix key acts as a signal that the next keystroke should be interpreted as a tmux command rather than being passed through to your terminal application. This mechanism is necessary because tmux runs on top of your terminal and needs a way to distinguish between regular input and tmux-specific commands.

How to use the prefix key:

  1. Press and hold Ctrl
  2. While holding Ctrl, press b
  3. Release both keys
  4. Press the tmux command key you want to execute

Common prefix-key combinations:

Ctrl+b cCreate a new window
Ctrl+b %Split pane vertically
Ctrl+b "Split pane horizontally
Ctrl+b arrowNavigate between panes

Changing the prefix key:

Many users find Ctrl+b awkward and prefer to change it. A popular alternative is Ctrl+a (same as GNU Screen). To change it, add these lines to your ~/.tmux.conf:

# Remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

Pro Tip

You can create a "prefix-less" environment for frequently used commands by mapping them directly to non-prefixed key combinations:

# Switch windows without prefix
bind -n M-Left previous-window
bind -n M-Right next-window

Double Prefix

Pressing the prefix key twice (e.g., Ctrl+b Ctrl+b) will send the prefix to the application running inside tmux. This is useful when working with nested tmux sessions or applications that also use the prefix key.