tmux: The Complete Guide for 2026

February 12, 2026

tmux (terminal multiplexer) lets you run multiple terminal sessions inside a single window, detach from them, and reattach later — even from a different computer. It is the single most important tool for anyone who works with remote servers, long-running processes, or complex development environments that require multiple terminals simultaneously. Once you learn tmux, you will never go back to opening dozens of terminal tabs.

This guide covers everything from installation to advanced workflows. Every section includes real commands you can run immediately. Whether you are managing production servers over SSH, developing locally with multiple services, or pair programming with a teammate, this is the reference you need.

⚙ Related resources: Keep our Bash Cheat Sheet open as a quick reference, and learn more terminal skills in Bash Scripting: The Complete Guide and Linux Commands: The Complete Guide.

Table of Contents

  1. What Is tmux and Why Use It
  2. Installation
  3. Sessions: Create, Attach, Detach, List, Kill
  4. Windows: Create, Rename, Switch, Close
  5. Panes: Split, Navigate, Resize, Zoom
  6. Key Bindings and the Prefix Key
  7. Copy Mode and Scrollback
  8. Custom .tmux.conf Configuration
  9. Status Bar Customization
  10. Plugins and TPM
  11. Scripting tmux
  12. Remote Server Workflows
  13. Pair Programming with tmux
  14. Frequently Asked Questions

1. What Is tmux and Why Use It

tmux is a terminal multiplexer: it lets you create multiple terminal sessions within a single terminal window, switch between them, and detach from them entirely while they continue running in the background. It was created by Nicholas Marriott and first released in 2007 as a modern replacement for GNU Screen.

Here is why tmux is essential for developers in 2026:

2. Installation

tmux is available in every major package manager. Install it for your platform:

# Ubuntu / Debian
sudo apt update && sudo apt install tmux

# Fedora / RHEL / CentOS
sudo dnf install tmux

# Arch Linux
sudo pacman -S tmux

# macOS (Homebrew)
brew install tmux

# macOS (MacPorts)
sudo port install tmux

# Verify installation
tmux -V
# tmux 3.5a

tmux requires no configuration to start using. The defaults are functional out of the box, and you can customize later once you understand the basics.

3. Sessions: Create, Attach, Detach, List, Kill

A session is the top-level container in tmux. Each session has one or more windows, and each window has one or more panes. Sessions persist in the background until you explicitly kill them or the server is rebooted.

# Start a new session (auto-named 0, 1, 2...)
tmux

# Start a new session with a name
tmux new-session -s dev
tmux new -s dev          # shorthand

# Detach from current session (keeps it running)
# Press: Ctrl-b d

# List all sessions
tmux list-sessions
tmux ls                  # shorthand

# Attach to a named session
tmux attach-session -t dev
tmux attach -t dev       # shorthand
tmux a -t dev            # even shorter

# Attach to the most recent session
tmux attach
tmux a

# Kill a specific session
tmux kill-session -t dev

# Kill all sessions except the current one
tmux kill-session -a

# Kill the tmux server (destroys everything)
tmux kill-server

# Rename the current session
# Press: Ctrl-b $

# Switch between sessions interactively
# Press: Ctrl-b s

A typical workflow: tmux new -s project-api to start a session for your API work, Ctrl-b d to detach when switching tasks, tmux new -s project-frontend for frontend work, and Ctrl-b s to see all sessions and jump between them.

4. Windows: Create, Rename, Switch, Close

Windows are like tabs within a session. Each window occupies the full terminal screen and can contain one or more panes. The status bar at the bottom shows all windows in the current session.

# Create a new window
# Press: Ctrl-b c

# Rename current window
# Press: Ctrl-b ,

# Switch to next window
# Press: Ctrl-b n

# Switch to previous window
# Press: Ctrl-b p

# Switch to window by number
# Press: Ctrl-b 0    (window 0)
# Press: Ctrl-b 1    (window 1)
# Press: Ctrl-b 2    (window 2)

# List windows interactively
# Press: Ctrl-b w

# Close current window (kills all panes in it)
# Press: Ctrl-b &
# Or just type: exit (in each pane)

# Move window to a different position
# Press: Ctrl-b .    (prompts for new index)

# From command line, create a named window
tmux new-window -n logs
tmux neww -n logs        # shorthand

A practical setup: window 0 named "editor" for your code, window 1 named "server" running your dev server, window 2 named "logs" tailing log files, and window 3 named "git" for version control operations. Use Ctrl-b w for a visual tree of all sessions and windows.

5. Panes: Split, Navigate, Resize, Zoom

Panes split a window into multiple terminals displayed side by side or stacked. This is where tmux becomes truly powerful — you can see your editor, server output, and test results simultaneously without switching windows.

# Split horizontally (top/bottom)
# Press: Ctrl-b "

# Split vertically (left/right)
# Press: Ctrl-b %

# Navigate between panes
# Press: Ctrl-b <arrow key>

# Zoom a pane to full screen (toggle)
# Press: Ctrl-b z

# Close current pane
# Press: Ctrl-b x    (asks for confirmation)

# Resize panes (hold Ctrl, press arrow repeatedly)
# Press: Ctrl-b Ctrl-<arrow key>

# Swap panes: Ctrl-b } (next) or Ctrl-b { (previous)
# Rotate layout: Ctrl-b Space
# Show pane numbers: Ctrl-b q (then press number to jump)
# Convert pane to window: Ctrl-b !
# Join pane from another window:
# tmux join-pane -s :2    # bring pane from window 2

Zooming (Ctrl-b z) is one of the most useful features: expand any pane to fill the entire window for focused work, then press Ctrl-b z again to return to the split layout.

6. Key Bindings and the Prefix Key

Every tmux command starts with the prefix key, which defaults to Ctrl-b. You press the prefix, release it, then press the command key. This two-step pattern prevents conflicts with programs running inside tmux.

Essential key bindings to memorize:

# Session management
Ctrl-b d        Detach from session
Ctrl-b s        List/switch sessions
Ctrl-b $        Rename session

# Window management
Ctrl-b c        Create window
Ctrl-b ,        Rename window
Ctrl-b n        Next window
Ctrl-b p        Previous window
Ctrl-b w        List all windows (tree view)
Ctrl-b 0-9      Jump to window by number
Ctrl-b &        Kill window

# Pane management
Ctrl-b "        Split horizontal
Ctrl-b %        Split vertical
Ctrl-b arrows   Navigate panes
Ctrl-b z        Zoom/unzoom pane
Ctrl-b x        Kill pane
Ctrl-b {        Move pane left
Ctrl-b }        Move pane right
Ctrl-b Space    Cycle layouts
Ctrl-b q        Show pane numbers
Ctrl-b !        Break pane to window

# Copy mode
Ctrl-b [        Enter copy mode
Ctrl-b ]        Paste from buffer

# Other
Ctrl-b :        Command prompt
Ctrl-b ?        List all key bindings
Ctrl-b t        Show clock

To see all current key bindings, press Ctrl-b ? inside tmux. This is the most useful reference when you forget a shortcut. Press q to exit the list.

7. Copy Mode and Scrollback

By default, you cannot scroll up in tmux with your mouse wheel or Page Up. You need to enter copy mode first. Copy mode also lets you search through output, select text, and copy it to tmux's paste buffer.

# Enter copy mode
# Press: Ctrl-b [

# In copy mode with vi keys (recommended):
# h/j/k/l    Move cursor
# Space      Start selection
# Enter      Copy selection and exit
# /          Search forward
# ?          Search backward
# n / N      Next / previous search match
# q          Exit copy mode

# Paste from buffer
# Press: Ctrl-b ]

To enable vi-style keys in copy mode (recommended if you use vim), add this to your ~/.tmux.conf:

# Use vi keys in copy mode
set-window-option -g mode-keys vi

# More intuitive vi copy bindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# Copy to system clipboard (Linux with xclip)
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"

# Copy to system clipboard (macOS)
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"

Increase scrollback buffer if you need more history (default is 2000 lines):

# In .tmux.conf: keep 50,000 lines of scrollback
set -g history-limit 50000

8. Custom .tmux.conf Configuration

tmux reads configuration from ~/.tmux.conf on startup. Here is a practical configuration file that addresses the most common complaints about tmux defaults:

# ~/.tmux.conf - Practical tmux configuration

# -------------------------------------------
# General settings
# -------------------------------------------

# Change prefix from Ctrl-b to Ctrl-a (easier to reach)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Start window numbering at 1 (not 0)
set -g base-index 1
setw -g pane-base-index 1

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

# Increase scrollback buffer
set -g history-limit 50000

# Reduce escape time (important for vim users)
set -sg escape-time 10

# Enable mouse support
set -g mouse on

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

# -------------------------------------------
# Key bindings
# -------------------------------------------

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

# Split panes with intuitive keys
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# New window in current directory
bind c new-window -c "#{pane_current_path}"

# Navigate panes with vim keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes with vim keys
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

# Vi copy mode
setw -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# -------------------------------------------
# Visual settings
# -------------------------------------------

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

# Pane borders
set -g pane-border-style fg=colour238
set -g pane-active-border-style fg=colour39

# Activity alerts
setw -g monitor-activity on
set -g visual-activity off

After editing ~/.tmux.conf, reload it without restarting tmux:

# From inside tmux (if you have the bind above)
# Press: Ctrl-a r

# Or from the command prompt
# Press: Ctrl-b :
# Type: source-file ~/.tmux.conf

# Or from the shell
tmux source-file ~/.tmux.conf

9. Status Bar Customization

The status bar is the information strip at the bottom of the tmux window. You can fully customize its content, colors, and layout.

# Status bar colors
set -g status-style bg=colour234,fg=colour250

# Left side: session name
set -g status-left-length 30
set -g status-left "#[fg=colour39,bold] #S #[default]| "

# Right side: date and time
set -g status-right-length 50
set -g status-right "#[fg=colour245]%Y-%m-%d #[fg=colour39]%H:%M "

# Window status formatting
setw -g window-status-format " #I:#W "
setw -g window-status-current-format "#[fg=colour234,bg=colour39,bold] #I:#W "

# Center the window list
set -g status-justify centre

Format variables you can use in the status bar:

10. Plugins and TPM (Tmux Plugin Manager)

TPM (Tmux Plugin Manager) is the standard way to install tmux plugins. Install it first:

# Clone TPM into the tmux plugins directory
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Add plugins to your ~/.tmux.conf:

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'      # sensible defaults
set -g @plugin 'tmux-plugins/tmux-resurrect'      # save/restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum'      # auto-save sessions
set -g @plugin 'tmux-plugins/tmux-yank'           # system clipboard
set -g @plugin 'christoomey/vim-tmux-navigator'   # vim-tmux pane nav

# Plugin settings
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'

# Initialize TPM (keep this at the very bottom)
run '~/.tmux/plugins/tpm/tpm'

After adding plugins, press Ctrl-b I (capital I) inside tmux to install them. Essential plugins:

11. Scripting tmux

tmux has a powerful command interface that lets you script entire session layouts. You can automate complex workspaces with a simple shell script.

Raw tmux scripting

#!/bin/bash
# dev-workspace.sh - Create a full development environment

SESSION="dev"

# Kill existing session if it exists
tmux kill-session -t $SESSION 2>/dev/null

# Create session with first window named "editor"
tmux new-session -d -s $SESSION -n editor

# Open editor
tmux send-keys -t $SESSION:editor "vim ." Enter

# Create second window for server
tmux new-window -t $SESSION -n server
tmux send-keys -t $SESSION:server "npm run dev" Enter

# Create third window with split panes for logs and tests
tmux new-window -t $SESSION -n monitor
tmux send-keys -t $SESSION:monitor "tail -f logs/app.log" Enter
tmux split-window -h -t $SESSION:monitor
tmux send-keys -t $SESSION:monitor "npm run test:watch" Enter

# Create fourth window for git
tmux new-window -t $SESSION -n git
tmux send-keys -t $SESSION:git "git status" Enter

# Select the first window
tmux select-window -t $SESSION:editor

# Attach to the session
tmux attach -t $SESSION

tmuxinator

tmuxinator provides a YAML-based approach to defining tmux sessions. Install it with gem install tmuxinator and create project files:

# ~/.tmuxinator/webapp.yml
name: webapp
root: ~/projects/webapp

windows:
  - editor:
      layout: main-vertical
      panes:
        - vim .
        - #empty pane for commands
  - server:
      panes:
        - npm run dev
  - logs:
      layout: even-horizontal
      panes:
        - tail -f logs/app.log
        - tail -f logs/error.log
  - database:
      panes:
        - psql -d myapp
# Start the project
tmuxinator start webapp

# Stop the project (kills the session)
tmuxinator stop webapp

# Edit the project config
tmuxinator edit webapp

# List all projects
tmuxinator list

tmux-resurrect for persistence

If you use the tmux-resurrect plugin, your sessions survive server reboots:

# Save current environment
# Press: Ctrl-b Ctrl-s
# Output: "Tmux environment saved!"

# Restore after restart
# Press: Ctrl-b Ctrl-r
# Output: "Tmux restore complete!"

# Resurrect saves: sessions, windows, pane layout,
# current directory per pane, and running programs

12. Remote Server Workflows (SSH + tmux)

The most impactful use of tmux is on remote servers. Here are the patterns every developer should know:

Basic remote workflow

# SSH into server and start/attach tmux
ssh user@server -t "tmux new -A -s main"
# -t forces a TTY allocation
# new -A means: attach if session exists, create if it doesn't

# Inside the session, run your long tasks
# Then detach with Ctrl-b d
# Your SSH connection can drop - the session survives

# Reconnect later
ssh user@server -t "tmux attach -t main"

Running deployments safely

# On the server, inside a tmux session:
tmux new -s deploy

# Run your deployment
./deploy.sh --production

# If SSH drops during deployment, reconnect:
ssh user@server -t "tmux a -t deploy"
# You will see exactly where the deployment is

Synchronized panes

Send the same keystrokes to all panes simultaneously — useful for running the same command on multiple servers:

# Toggle synchronized input for all panes in the current window
# Press: Ctrl-b :
# Type: setw synchronize-panes on

# Now everything you type goes to ALL panes
sudo apt update && sudo apt upgrade -y

# Turn off sync when done
# Press: Ctrl-b :
# Type: setw synchronize-panes off

13. Pair Programming with tmux

tmux enables real-time collaborative terminal sharing. Both developers see the same session and can type simultaneously.

Same server (simplest)

# Developer A starts a session on the shared server
tmux new -s pairing

# Developer B attaches to the same session
tmux attach -t pairing

# Both see the same windows and panes in real time
# Both can type - this is truly shared control

Independent views of the same session

# Developer A
tmux new -s pairing

# Developer B attaches but can view different windows
tmux new-session -t pairing -s pair-b

# Both share the same session group (same windows/panes)
# but each can independently look at different windows

Remote pairing with tmate

tmate is a fork of tmux designed specifically for pair programming over the internet. It creates a secure SSH connection through a relay server:

# Install tmate
sudo apt install tmate    # Ubuntu/Debian
brew install tmate         # macOS

# Start a tmate session
tmate

# tmate prints SSH connection strings:
# ssh ro-XXXXX@nyc1.tmate.io    (read-only)
# ssh XXXXX@nyc1.tmate.io       (read-write)

# Share the appropriate URL with your pair partner
# They connect with: ssh XXXXX@nyc1.tmate.io

Frequently Asked Questions

What is the difference between tmux and screen?

Both are terminal multiplexers, but tmux is the modern successor with active development. tmux offers better pane management (horizontal and vertical splits), a powerful scripting interface, true color support, vi and emacs key binding modes, a highly customizable status bar, and a rich plugin ecosystem through TPM. GNU Screen has been in maintenance mode for years. The main reason to use Screen today is if tmux is not available on a legacy system. For new setups, always choose tmux.

How do I keep a process running after disconnecting from SSH?

Start a tmux session on the server with tmux new -s work, run your process inside it, then detach with Ctrl-b d. Close your SSH connection safely. The process continues running inside the tmux session. When you reconnect later, run tmux attach -t work to reattach and see all output. This is the standard approach for long-running tasks on remote servers and is more reliable than nohup or background jobs.

How do I copy text in tmux?

Press Ctrl-b [ to enter copy mode. Navigate to the text, press Space (vi mode) or Ctrl-Space (emacs mode) to start selection, move to the end, then press Enter (vi) or Alt-w (emacs) to copy. Press Ctrl-b ] to paste. For system clipboard integration, use the tmux-yank plugin or add a custom binding that pipes through xclip (Linux) or pbcopy (macOS). Enable set -g mouse on to scroll with your mouse wheel.

Can I use the mouse in tmux?

Yes. Add set -g mouse on to your ~/.tmux.conf and reload the config. Mouse mode lets you click to select panes, drag borders to resize panes, scroll the mouse wheel to enter copy mode and browse scrollback history, and click windows in the status bar. It works in iTerm2, Alacritty, WezTerm, Windows Terminal, GNOME Terminal, and most other modern emulators.

How do I change the prefix key from Ctrl-b?

Add these lines to ~/.tmux.conf: unbind C-b, set -g prefix C-a, and bind C-a send-prefix. This changes the prefix to Ctrl-a, which matches GNU Screen and is easier to reach. Popular alternatives include Ctrl-Space and backtick. The send-prefix binding lets you send the actual prefix key to a program inside tmux by pressing it twice (e.g., Ctrl-a Ctrl-a).

Conclusion

tmux is one of those tools that fundamentally changes how you work with terminals. Session persistence means you never lose work to a dropped SSH connection. Panes and windows let you build focused workspaces without juggling terminal tabs. Scriptable layouts mean your development environment is reproducible with a single command. And the plugin ecosystem (resurrect, continuum, yank) fills every remaining gap.

If you are new to tmux, start with three things: learn to create sessions (tmux new -s name), learn to split panes (Ctrl-b " and Ctrl-b %), and learn to detach and reattach (Ctrl-b d and tmux attach). Once those are muscle memory, customize your .tmux.conf to change the prefix key, enable mouse support, and add intuitive split bindings. Then install TPM and tmux-resurrect for session persistence.

The developers who get the most out of tmux are the ones who invest an afternoon in configuration and then use it for everything. Every SSH session, every local dev environment, every pair programming session — all through tmux. The compound productivity gains are enormous.

📚 Continue learning: Bash Scripting: The Complete GuideLinux Commands: The Complete GuideVS Code Tips: The Complete Guide

Related Resources

Related Tools

Bash Cheat Sheet
Quick reference for bash commands, syntax, and patterns
Crontab Generator
Schedule automated tasks to run in your tmux sessions
Bash Scripting Guide
Write scripts to automate your tmux workspace setup
Linux Commands Guide
Master the commands you use inside tmux every day
Docker Complete Guide
Containerize applications and manage them from tmux
Git Complete Guide
Version control workflows for your development sessions