tmux Cheat Sheet: Sessions, Windows, Panes and Keys

tmux terminal linux command-line productivity

tmux is a terminal multiplexer: it keeps sessions alive after you disconnect, splits the screen into panes, and manages multiple windows in a single terminal. This tmux cheat sheet organizes every command by workflow phase — installation, sessions, windows, panes, copy mode, and configuration. Whether you’re new to tmux or looking for a quick reference, start from the top.

tmux Cheat Sheet: Installation and First Launch

Before the keybindings matter, you need tmux installed and running. Here’s how to get it on common platforms:

PlatformCommand
Ubuntu / Debiansudo apt install tmux
macOS (Homebrew)brew install tmux
Fedora / RHELsudo dnf install tmux
Arch Linuxsudo pacman -S tmux
From source./configure && make && sudo make install

After installation, verify the version to confirm it worked:

tmux -V
# tmux 3.4 (or similar output)

The default prefix key is Ctrl+b. Every keybinding below uses prefix to mean pressing Ctrl+b first, then the letter or symbol that follows. For example, prefix d means: press Ctrl+b, release, then press d.

Starting tmux

CommandWhat It Does
tmuxStart a new unnamed session
tmux new -s workStart a new session named “work”
tmux -uStart with UTF-8 support enabled

Session Management

A tmux session is a persistent workspace that survives terminal disconnection. You can run multiple sessions simultaneously, each with independent windows and panes. Sessions stay alive as long as the tmux server process is running — typically until you reboot or explicitly kill them.

CommandWhat It Does
tmux lsList all active sessions
tmux attachAttach to the most recent session
tmux attach -t workAttach to the session named “work”
tmux kill-session -t workKill the session named “work”
tmux kill-serverKill all sessions and stop the tmux server
prefix dDetach from the current session (session keeps running)
prefix $Rename the current session
prefix sShow an interactive session picker
prefix (Switch to the previous session
prefix )Switch to the next session
prefix LSwitch to the last (previously used) session

Typical session workflow

# Morning: start a named session
tmux new -s dev

# Work for a while, then detach without killing it
# (inside tmux): prefix d

# Later, list what's running
tmux ls
# dev: 2 windows (created Mon Jun 14 09:00:12 2026) [220x50]

# Reattach — even after an SSH reconnect
tmux attach -t dev

Named sessions are worth the habit. When you have api, frontend, and infra sessions running alongside each other, tmux attach -t api is faster than rebuilding your working environment from scratch.

Window Management

Windows inside a session act like browser tabs — each one has its own shell. You can name them to match what you’re running, and switch between them without mouse clicks.

CommandWhat It Does
prefix cCreate a new window
prefix ,Rename the current window
prefix wShow an interactive window picker
prefix nMove to the next window
prefix pMove to the previous window
prefix 0–9Jump directly to window by index
prefix &Kill the current window (prompts for confirmation)
prefix .Move window to a different index
prefix fSearch for a window by name
prefix lSwitch to the last (previously active) window

Naming windows by workload

# Open tmux and create four named windows:
# prefix c  → prefix ,  → type 'server'   → Enter
# prefix c  → prefix ,  → type 'db'       → Enter
# prefix c  → prefix ,  → type 'logs'     → Enter
# prefix c  → prefix ,  → type 'notes'    → Enter

# Navigate by name via the picker:
# prefix w   → arrow keys → Enter

# Or jump directly by index:
# prefix 1  →  server
# prefix 2  →  db
# prefix 3  →  logs

The status bar at the bottom of the screen shows your windows by name and highlights the active one. After a few days with named windows, you stop looking at terminal titles entirely.

Pane Management

Panes split a single window into multiple terminal areas arranged vertically or horizontally. Running a server process in one pane and tailing logs in another — without switching windows — is the main reason developers reach for tmux.

CommandWhat It Does
prefix %Split pane vertically (left/right)
prefix "Split pane horizontally (top/bottom)
prefix oCycle to the next pane
prefix ;Toggle between the two most recently active panes
prefix qFlash pane index numbers
prefix q 0–9Jump to a pane by its index number
prefix xKill the current pane (prompts for confirmation)
prefix zToggle full-screen zoom on the current pane
prefix {Swap the current pane with the previous pane
prefix }Swap the current pane with the next pane
prefix !Break current pane into its own window
prefix SpaceRotate through built-in pane layouts
prefix Ctrl+arrowResize pane one cell in the arrow direction
prefix Alt+arrowResize pane five cells in the arrow direction

Three-pane development setup

# Start with one window, then build a layout:

# 1. Split vertically — left and right halves
# prefix %

# 2. Move to right pane and split horizontally
# prefix o
# prefix "

# Result:
# +--------------------+----------+
# |                    |  server  |
# |   code editor      +----------+
# |                    |   logs   |
# +--------------------+----------+

# Zoom into the server pane to read output:
# prefix z

# Zoom back out (same key):
# prefix z

prefix z is one of the most useful pane shortcuts: it temporarily fills the window with the active pane for focus, then restores the layout when pressed again. No resizing needed.

Copy Mode and Scrollback

tmux keeps a scrollback buffer for each pane. Copy mode lets you navigate it, search for text, and copy selections — all with keyboard shortcuts. By default, keybindings follow emacs conventions; most developers switch to vi mode.

CommandWhat It Does
prefix [Enter copy mode
q or EscapeExit copy mode
Arrow keysMove cursor one character or line
Ctrl+bScroll up half a page
Ctrl+fScroll down half a page
PgUp / PgDnScroll up / down a full page
gJump to the top of the buffer
GJump to the bottom of the buffer
/Search forward
?Search backward
nJump to the next search match
NJump to the previous search match
SpaceStart selection (vi mode)
EnterCopy selection to the tmux paste buffer
prefix ]Paste from the paste buffer into the active pane

Enabling vi keybindings in copy mode

Add the following to ~/.tmux.conf to use familiar vi motions for navigation and selection:

# Use vi keybindings in copy mode
setw -g mode-keys vi

# v starts selection, y yanks it (like Vim visual mode)
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# Also copy to the system clipboard (requires xclip on Linux)
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"

With vi mode active: prefix [ enters copy mode, v starts selection, y yanks. prefix ] pastes. This matches the workflow muscle memory from Vim and Neovim users.

tmux Configuration

tmux reads ~/.tmux.conf on startup. The defaults are functional but sparse. The config below covers the most common quality-of-life adjustments:

# ~/.tmux.conf

# Change prefix from Ctrl+b to Ctrl+a (screen-style, easier to reach)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Enable mouse support — click to switch panes and resize
set -g mouse on

# Start window and pane indices at 1 (keyboard layout matches)
set -g base-index 1
setw -g pane-base-index 1

# Renumber windows automatically when one is closed
set -g renumber-windows on

# Reload config inside tmux without restarting
bind r source-file ~/.tmux.conf \; display-message "Config reloaded"

# More intuitive split keybindings
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# New windows and panes open in the current directory
bind c new-window -c "#{pane_current_path}"

# Move between panes with vi-style hjkl
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# vi keybindings in copy mode
setw -g mode-keys vi

# Increase scrollback history
set -g history-limit 50000

# Reduce escape-time (critical for Vim/Neovim responsiveness)
set -sg escape-time 10

# Enable 256-color and true-color support
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

# Status bar
set -g status-position bottom
set -g status-interval 5

After saving changes, reload the config from inside a running tmux session:

tmux source-file ~/.tmux.conf
# Or use prefix r if you added the bind above

Quick Reference: Miscellaneous Commands

CommandWhat It Does
prefix ?List all active keybindings
prefix :Open the tmux command prompt
prefix tShow a clock in the current pane
prefix ~Show tmux server messages
prefix iDisplay information about the current window
tmux infoPrint full tmux server environment info
tmux show-options -gShow all global options

prefix ? is the binding to remember first. It shows the full keybinding list from inside the running session. You don’t need to memorize everything on this page — just remember that prefix ? puts the reference one keypress away.

Conclusion

This tmux cheat sheet covers the complete workflow: installing tmux, managing sessions that outlive your SSH connection, organizing work across named windows, splitting panes for parallel visibility, navigating the scrollback buffer in copy mode, and tuning behavior through ~/.tmux.conf. The session, window, and pane commands handle the vast majority of daily use — the rest you can look up with prefix ? or the official tmux man page. For more terminal reference material, the Linux commands cheatsheet, Git commands cheatsheet, and Docker commands cheatsheet cover the tools you’re most likely running inside those panes. The tmux GitHub wiki is the authoritative source for options not covered here.