Tmux Command Reference

13 October 2025 · Updated 13 October 2025

commandstmuxterminalmultiplexershellreference

Working reference for tmux — the commands I actually use for managing sessions, windows, and panes over SSH. Grouped by what you’re trying to do rather than alphabetically.

Session Management

Start New Session

tmux

Use when: Starting a new default tmux session

Start Named Session

tmux new -s session-name

Use when: Creating a session with a specific name for easy identification

List All Sessions

tmux ls

Alternative:

tmux list-sessions

Use when: Checking active tmux sessions before attaching

Attach to Last Session

tmux attach

Alternative:

tmux a

Use when: Reconnecting to your most recent tmux session

Attach to Named Session

tmux attach -t session-name

Alternative:

tmux a -t session-name

Use when: Connecting to a specific named session

Detach from Session

Ctrl+b d

Use when: Leaving a session running in the background while disconnecting

Kill Session

tmux kill-session -t session-name

Use when: Terminating a specific session and all its windows/panes

Kill All Sessions

tmux kill-server

Use when: Terminating all tmux sessions at once (use with caution)

Rename Current Session

Ctrl+b $

Use when: Changing the name of your active session for better organization


Window Management

Create New Window

Ctrl+b c

Use when: Adding another terminal window to your session

Switch to Next Window

Ctrl+b n

Use when: Moving forward through your window list

Switch to Previous Window

Ctrl+b p

Use when: Moving backward through your window list

Switch to Window by Number

Ctrl+b 0-9

Use when: Jumping directly to a numbered window (0-9)

List All Windows

Ctrl+b w

Use when: Viewing and selecting from all windows interactively

Rename Current Window

Ctrl+b ,

Use when: Giving descriptive names to windows (e.g., “logs”, “editor”, “server”)

Kill Current Window

Ctrl+b &

Use when: Closing a window and all its panes (with confirmation)

Find Window

Ctrl+b f

Use when: Searching for a window by name


Pane Management

Split Pane Horizontally

Ctrl+b "

Use when: Creating a new pane below the current one

Split Pane Vertically

Ctrl+b %

Use when: Creating a new pane to the right of the current one

Switch Between Panes

Ctrl+b arrow-key

Use when: Moving focus between panes using arrow keys

Switch to Next Pane

Ctrl+b o

Use when: Cycling through panes in order

Toggle Last Active Pane

Ctrl+b ;

Use when: Quickly switching between two panes

Show Pane Numbers

Ctrl+b q

Use when: Identifying pane numbers (type number while visible to switch)

Kill Current Pane

Ctrl+b x

Use when: Closing the active pane (with confirmation)

Toggle Pane Zoom

Ctrl+b z

Use when: Maximizing/restoring a pane to full window size

Convert Pane to Window

Ctrl+b !

Use when: Breaking a pane out into its own window

Move Pane to Different Window

Ctrl+b : join-pane -t :target-window

Use when: Reorganizing panes across windows

Resize Panes with Arrow Keys (Default Method)

Resize Pane Up

Ctrl+b Ctrl+arrow-up

Use when: Making the current pane taller (press repeatedly for incremental resize)

Resize Pane Down

Ctrl+b Ctrl+arrow-down

Use when: Making the current pane shorter

Resize Pane Left

Ctrl+b Ctrl+arrow-left

Use when: Making the current pane narrower (useful for side-by-side panes)

Resize Pane Right

Ctrl+b Ctrl+arrow-right

Use when: Making the current pane wider (useful for side-by-side panes)

Tip: Hold Ctrl after the prefix and press arrow keys multiple times for continuous resizing

Resize Panes by Specific Amount

Resize Left by N Cells

Ctrl+b : resize-pane -L 10

Use when: Need precise control over pane width (reduces current pane width)

Resize Right by N Cells

Ctrl+b : resize-pane -R 10

Use when: Need precise control over pane width (increases current pane width)

Resize Up by N Cells

Ctrl+b : resize-pane -U 5

Use when: Need precise control over pane height (reduces current pane height)

Resize Down by N Cells

Ctrl+b : resize-pane -D 5

Use when: Need precise control over pane height (increases current pane height)

Examples:

# Make current pane much wider (20 cells)
Ctrl+b : resize-pane -R 20

# Make current pane slightly narrower (3 cells)
Ctrl+b : resize-pane -L 3

# Increase height significantly (15 cells)
Ctrl+b : resize-pane -D 15

Resize to Percentage of Window

Resize to Specific Percentage Width

Ctrl+b : resize-pane -x 50%

Use when: Want exact 50/50 split or other percentage (e.g., 30%, 70%)

Resize to Specific Percentage Height

Ctrl+b : resize-pane -y 75%

Use when: Want specific height ratio between panes

Examples:

# Make left pane 30% of window width
Ctrl+b : resize-pane -t 0 -x 30%

# Make top pane 25% of window height
Ctrl+b : resize-pane -t 0 -y 25%

Quick Even Distribution

Make All Panes Equal Width (Side-by-Side)

Ctrl+b M-1

Use when: Resetting side-by-side panes to equal widths

Make All Panes Equal Height (Stacked)

Ctrl+b M-2

Use when: Resetting stacked panes to equal heights

Cycle Through Pane Layouts

Ctrl+b Space

Use when: Automatically arranging panes in different preset layouts


Copy Mode (Scrollback)

Enter Copy Mode

Ctrl+b [

Use when: Scrolling through terminal history or copying text

Exit Copy Mode

q

Use when: Leaving copy mode and returning to normal operation

Arrow keys, Page Up/Down, h/j/k/l (vi mode)

Use when: Moving through scrollback buffer

Start Selection (vi mode)

Space

Use when: Beginning text selection in copy mode

Copy Selection (vi mode)

Enter

Use when: Copying selected text to tmux clipboard

Paste Buffer

Ctrl+b ]

Use when: Pasting previously copied text from tmux clipboard

Search Backward in Copy Mode

Ctrl+b ?

Use when: Searching for text above cursor position

Search Forward in Copy Mode

Ctrl+b /

Use when: Searching for text below cursor position


Command Mode

Enter Command Mode

Ctrl+b :

Use when: Executing tmux commands directly

Common Command Mode Operations

Create Named Window

Ctrl+b : new-window -n window-name

Rename Session from Command Mode

Ctrl+b : rename-session new-name

Set Pane Synchronization (type in all panes)

Ctrl+b : setw synchronize-panes on

Use when: Executing the same commands across multiple panes simultaneously

Disable Pane Synchronization

Ctrl+b : setw synchronize-panes off

Configuration

Reload Configuration File

Ctrl+b : source-file ~/.tmux.conf

Use when: Applying changes made to your tmux configuration

Alternative: Reload from Shell

tmux source-file ~/.tmux.conf

Use when: Reloading config outside of tmux


Status and Information

Show Clock

Ctrl+b t

Use when: Checking current time

Display Tmux Information

Ctrl+b i

Use when: Viewing session, window, and pane info

List Key Bindings

Ctrl+b ?

Use when: Viewing all available keyboard shortcuts


Advanced Session Management

Create Detached Session

tmux new -d -s session-name

Use when: Starting a session in the background without attaching

Create Session with Window Name

tmux new -s session-name -n window-name

Use when: Creating a session and naming the first window

Create Session with Command

tmux new -s session-name 'command'

Use when: Starting a session that runs a specific command

Switch Between Sessions

Ctrl+b (  # Previous session
Ctrl+b )  # Next session

Use when: Navigating between multiple active sessions

Choose Session from List

Ctrl+b s

Use when: Interactively selecting from all sessions


Working with Multiple Panes

Even Horizontal Layout

Ctrl+b M-1

Use when: Arranging panes side-by-side evenly

Even Vertical Layout

Ctrl+b M-2

Use when: Stacking panes vertically with equal heights

Main Horizontal Layout

Ctrl+b M-3

Use when: Creating one large top pane with smaller panes below

Main Vertical Layout

Ctrl+b M-4

Use when: Creating one large left pane with smaller panes to the right

Tiled Layout

Ctrl+b M-5

Use when: Arranging panes in a grid pattern


Scripting and Automation

Create Window and Run Command

tmux new-window -n logs 'tail -f /var/log/syslog'

Use when: Automating window creation with specific tasks

Send Keys to Session

tmux send-keys -t session-name:window.pane 'command' C-m

Use when: Automating command execution in specific panes

Capture Pane Content

tmux capture-pane -t session-name:window.pane -p

Use when: Extracting terminal output programmatically

Create Multi-Pane Layout Script Example

#!/bin/bash
# Create a development environment session

tmux new-session -d -s dev -n editor
tmux send-keys -t dev:editor 'nvim' C-m

tmux new-window -t dev -n server
tmux send-keys -t dev:server 'npm run dev' C-m

tmux new-window -t dev -n logs
tmux split-window -h -t dev:logs
tmux send-keys -t dev:logs.0 'tail -f app.log' C-m
tmux send-keys -t dev:logs.1 'htop' C-m

tmux select-window -t dev:editor
tmux attach -t dev

Use when: Setting up complex, reproducible tmux environments


Configuration Tips

Sample ~/.tmux.conf

# Set prefix to Ctrl+a (optional, default is Ctrl+b)
# set -g prefix C-a
# unbind C-b
# bind C-a send-prefix

# Enable mouse support
set -g mouse on

# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

# Vi mode for copy
setw -g mode-keys vi

# Increase scrollback buffer
set -g history-limit 10000

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Reload config
bind r source-file ~/.tmux.conf \; display "Config reloaded!"

# Fast pane switching with Alt+arrow (no prefix)
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Fast pane resizing with Alt+Shift+arrow (no prefix)
bind -n M-S-Left resize-pane -L 5
bind -n M-S-Right resize-pane -R 5
bind -n M-S-Up resize-pane -U 5
bind -n M-S-Down resize-pane -D 5

# Alternative: Vim-style pane resizing (with prefix)
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# Status bar customization
set -g status-style bg=black,fg=white
set -g status-left '#[fg=green]#S '
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M'

Resize keybinding explanation:

  • bind -n = no prefix required (instant access)
  • bind -r = repeatable (hold prefix once, press key multiple times)
  • M-S- = Alt+Shift (Meta+Shift)
  • Numbers indicate resize increment in cells

With these keybindings:

# After adding to ~/.tmux.conf and reloading:

# Without prefix (instant):
Alt+Shift+Left/Right/Up/Down    # Resize panes by 5 cells

# With prefix (vim-style, repeatable):
Ctrl+b H (hold) H H H           # Resize left repeatedly
Ctrl+b L (hold) L L L           # Resize right repeatedly

Common Use Cases

Long-Running Processes

# Start session and run command
tmux new -s backup 'rsync -av /source /dest'

# Detach and let it run
Ctrl+b d

# Check progress later
tmux attach -t backup

Use when: Running backups, builds, or downloads that shouldn’t be interrupted

Remote Server Work

# SSH to server and start tmux
ssh user@server
tmux new -s work

# Do work, then detach
Ctrl+b d

# Log out (tmux keeps running)
exit

# Reconnect later and resume
ssh user@server
tmux attach -t work

Use when: Maintaining persistent sessions across SSH disconnections

Development Environment

# Create session with multiple panes
tmux new -s dev
Ctrl+b %  # Split vertically for editor/terminal
Ctrl+b "  # Split bottom for logs

Use when: Setting up a multi-pane development workspace


Troubleshooting

Session Already Attached Error

# Force attach (detach other clients)
tmux attach -d -t session-name

Use when: Session is attached in another terminal

Fix Display Issues After Resize

Ctrl+b : refresh-client

Use when: Terminal size becomes misaligned

Reset Pane

Ctrl+b : respawn-pane -k

Use when: A pane becomes unresponsive


  • Linux Command Reference - General Linux commands
  • ZSH Configuration - Shell customization
  • SSH Command Reference - Remote session management

Tips and Best Practices

Session Naming

  • Use descriptive names: tmux new -s project-name not tmux new -s s1
  • Group related work in named sessions (e.g., “backend”, “frontend”, “monitoring”)

Pane Organization

  • Split horizontally (”) for log monitoring alongside commands
  • Split vertically (%) for side-by-side code editing and terminal
  • Use zoom (Ctrl+b z) to focus on one pane temporarily

Pane Resizing Best Practices

  • Use Ctrl+b M-1 for quick equal-width distribution when panes get messy
  • For precise layouts, use percentage-based resizing: resize-pane -x 30%
  • Add custom keybindings to ~/.tmux.conf for faster access without prefix
  • Remember: -L/-R adjust width, -U/-D adjust height
  • Use repeatable bindings (bind -r) to resize continuously with one prefix press

Persistence Strategy

  • Always use named sessions for important work
  • Detach (don’t exit) when leaving work that should continue
  • Create startup scripts for common multi-pane layouts

Performance

  • Limit history-limit in config if memory is constrained
  • Close unused panes and windows regularly
  • Kill zombie sessions: tmux kill-session -a (kills all except current)