Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Tmux Keyboard Shortcuts: The Essential Cheat Sheet

· 4 min read · Home Tech

In this article
  1. Understanding the Prefix Key
  2. Session, Window, and Pane Basics
  3. Copy Mode and Scrolling
  4. Resizing Panes and Adjusting Layout
  5. Customizing Shortcuts
  6. Common Problems and Fixes
  7. Frequently Asked Questions

Tmux keyboard shortcuts let you control every feature of the terminal multiplexer without touching the mouse. You press a prefix key (by default Ctrl-b), release it, then press a command key to create windows, split panes, navigate, scroll, and manage sessions. This article explains the most important shortcuts, how the prefix system works, and how to customize it for your workflow.

Understanding the Prefix Key

Tmux uses a two-key sequence for nearly all commands. The default prefix is Ctrl-b (hold Control, press b). You press and release the prefix, then press the next key. For example, to create a new window, you press Ctrl-b then c. This is often written as Ctrl-b c or C-b c.

You can change the prefix to something more comfortable, like Ctrl-a (common for former GNU Screen users) or the backtick key. Add this to your ~/.tmux.conf:

set -g prefix C-a
unbind C-b
bind C-a send-prefix

After changing the prefix, all shortcuts below use your new prefix instead of Ctrl-b.

Session, Window, and Pane Basics

Tmux organizes your work into three levels: sessions (a collection of windows), windows (like tabs), and panes (splits within a window). Here are the essential shortcuts for each:

  • New session: tmux new -s name (outside tmux) or Ctrl-b : new-session inside.
  • Detach session: Ctrl-b d – leaves tmux running in the background.
  • List sessions: tmux ls (outside) or Ctrl-b s (inside).
  • Create window: Ctrl-b c
  • Next/previous window: Ctrl-b n / Ctrl-b p
  • Close window: Ctrl-b & (confirm with y)
  • Split pane horizontally: Ctrl-b % (left/right)
  • Split pane vertically: Ctrl-b " (top/bottom)
  • Move between panes: Ctrl-b arrow keys or Ctrl-b o (cycle)
  • Close pane: Ctrl-b x (confirm with y)

Copy Mode and Scrolling

By default, the mouse wheel does not scroll in tmux. To scroll back through terminal output, enter copy mode with Ctrl-b [. Then use arrow keys or Page Up/Page Down to move. To exit, press q or Enter.

In copy mode, you can select text with the spacebar and copy it with Enter. The copied text goes into tmux's paste buffer. To paste it, press Ctrl-b ].

If you prefer mouse scrolling, enable it in your config:

set -g mouse on

With mouse mode on, you can scroll with the wheel, click to select panes, and resize them by dragging the borders.

Resizing Panes and Adjusting Layout

Panes start at equal size, but you can resize them. The default resize commands are clunky: Ctrl-b Ctrl-arrow resizes by one row/column. To make resizing faster, add these bindings to your config:

bind -r C-Left resize-pane -L 5
bind -r C-Right resize-pane -R 5
bind -r C-Up resize-pane -U 5
bind -r C-Down resize-pane -D 5

The -r flag allows repeating the command without pressing the prefix again. You can also use Ctrl-b space to cycle through preset layouts (even horizontal, even vertical, main-horizontal, etc.).

Customizing Shortcuts

You can rebind any key in ~/.tmux.conf. The syntax is:

bind key command

For example, to make Ctrl-b r reload your config:

bind r source-file ~/.tmux.conf

To unbind a default key, use unbind key. For instance, many users unbind the default pane navigation to use Vim-style keys:

unbind h
bind h select-pane -L
unbind j
bind j select-pane -D
unbind k
bind k select-pane -U
unbind l
bind l select-pane -R

Remember to reload the config after editing (Ctrl-b : source-file ~/.tmux.conf or restart tmux).

Common Problems and Fixes

Problem: The prefix key doesn't work when using SSH.
Fix: This usually happens when your terminal emulator intercepts the key combination. Try a different terminal or change the prefix to something like Ctrl-a.

Problem: Scrolling doesn't work.
Fix: Enable mouse mode with set -g mouse on or use copy mode (Ctrl-b [).

Problem: Copy and paste doesn't work with the system clipboard.
Fix: Tmux has its own clipboard. To integrate with the system clipboard, you need a tool like xclip (Linux) or pbcopy (macOS). Add this to your config:

bind C-c run "tmux save-buffer - | xclip -i -selection clipboard"
bind C-v run "xclip -o -selection clipboard | tmux load-buffer -"

Adjust the commands for your OS.

Frequently Asked Questions

What is the default prefix key in tmux?

The default prefix is Ctrl-b. You press and release it, then press the command key. For example, Ctrl-b c creates a new window.

How do I detach and reattach to a tmux session?

Detach with Ctrl-b d. To reattach, run tmux attach -t session-name from the terminal. If you don't know the name, use tmux ls to list sessions.

How do I scroll up in tmux without a mouse?

Enter copy mode with Ctrl-b [, then use arrow keys or Page Up/Page Down to scroll. Press q to exit copy mode.

Can I use tmux with a mouse?

Yes. Add set -g mouse on to your ~/.tmux.conf. This enables scrolling, clicking to select panes, and resizing by dragging borders.

How do I kill a tmux session?

From inside the session, type exit in every pane/window, or press Ctrl-b & to kill the current window. To kill a session from outside, use tmux kill-session -t name.

What is the difference between a window and a pane?

A window is like a tab in a browser; it takes the full screen. A pane is a split within a window, allowing multiple shells side by side. You can have multiple panes in one window, and multiple windows in one session.