Why You Need tmux
Your work keeps running even if the SSH connection drops. Run deploy scripts, builds, and monitoring inside tmux, and they continue on the server even when a network issue disconnects your session.
Session Management
Bash
# Start a new session
tmux new -s deploy
# List sessions
tmux ls
# Reattach to a session (come back after detach)
tmux attach -t deploy
# Kill a session
tmux kill-session -t deployKey Bindings (default prefix: Ctrl+b)
| Shortcut | Action |
|---|---|
Ctrl+b d | Detach session (session stays alive) |
Ctrl+b c | Create a new window |
Ctrl+b n / p | Next / previous window |
Ctrl+b 0~9 | Jump to window by number |
Ctrl+b % | Split pane vertically |
Ctrl+b " | Split pane horizontally |
Ctrl+b arrow keys | Move between panes |
Ctrl+b z | Toggle current pane zoom (fullscreen) |
Ctrl+b [ | Enter scroll mode (q to exit) |
Ctrl+b , | Rename window |
Recommended ~/.tmux.conf Settings
Bash
# Change prefix to Ctrl+a (optional)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Enable mouse (scroll, click panes)
set -g mouse on
# Start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Status bar colors
set -g status-bg colour235
set -g status-fg colour136
# Increase history size
set -g history-limit 10000
# Reload config immediately
bind r source-file ~/.tmux.conf \; display "Config reloaded!"Apply the config: Ctrl+b r or tmux source ~/.tmux.conf
Practical Patterns
Bash
# Set up a deploy session (automated)
tmux new-session -d -s prod -n monitor
tmux send-keys -t prod:monitor "htop" Enter
tmux new-window -t prod -n logs
tmux send-keys -t prod:logs "tail -f /var/log/app/app.log" Enter
tmux new-window -t prod -n shell
tmux attach -t prod
# Type into multiple panes at once (synchronize)
# Ctrl+b :setw synchronize-panes onCopying in Scroll Mode
- Enter scroll mode with
Ctrl+b [ - Move with arrow keys or PageUp/PageDown
- Start selection with
Space, then extend the range with arrow keys - Copy with
Enter(tmux clipboard) - Paste with
Ctrl+b ]
Editorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗
Questions & answers
Ask a question about this guide. We'll review and reply.