tmux

tmux is a modern terminal multiplexer — like GNU Screen, it runs persistent shell sessions that survive disconnection, but with a cleaner architecture, first-class window splitting, and a scriptable client/server design. Start work over SSH, detach, reconnect from another machine, and reattach to the same live session. Its killer trait beyond persistence is layout: effortless panes and windows that turn one terminal into a full workspace. This guide covers installation, the detach/reattach workflow, panes and windows, and a starter config.

Tool: tmux  ·  Type: terminal multiplexer  ·  Prefix: Ctrl-b  ·  Config: ~/.tmux.conf
01 — The Model: Sessions, Windows, Panes

tmux has a clean three-level hierarchy. Grasping it up front makes everything else obvious — it's the main thing that separates tmux from Screen's flatter design.

LevelWhat it is
SessionThe persistent top-level container that survives detach. You attach and detach from sessions
WindowLike a tab within a session — a full-screen workspace; a session holds many
PaneA split within a window — multiple shells visible side by side at once
ℹ  Mental model: a session is your whole project, its windows are tabs (edit / logs / shell), and panes tile several shells inside one tab. The status bar along the bottom shows the session name and its window tabs at all times.
ℹ  tmux vs Screen: tmux uses a client/server model (one server hosts every session), has native, sane pane splitting, a fully scriptable command set, and easy customization. Screen is older and more universally preinstalled. If you're choosing fresh, most people pick tmux.
02 — Install

tmux is packaged everywhere. Pick your platform.

Debian / Ubuntu
sudo apt update && sudo apt install -y tmux
RHEL / CentOS / Fedora / Rocky / Alma
sudo dnf install -y tmux # older: sudo yum install -y tmux
Arch
sudo pacman -S tmux
openSUSE
sudo zypper install tmux
macOS (Homebrew)
brew install tmux
Verify
tmux -V
ℹ  A tmux 3.x release is current on modern distros; some config syntax (like bind -N notes) needs 3.1+, so check tmux -V if a config line is rejected. On minimal container images tmux isn't present by default — the one-liner adds it.
03 — The Prefix Key

Every tmux keyboard command starts with a prefix: Ctrl-b. Press the prefix, release, then the command key. Throughout this guide Ctrl-b d means "press Ctrl and b together, release, then press d."

NotationMeans
Ctrl-b dPrefix, then d — detach
Ctrl-b ?Prefix, then ? — list every key binding
Ctrl-b :Prefix, then : — open the tmux command prompt
ℹ  Many people remap the prefix from Ctrl-b to Ctrl-a (Screen's prefix, easier to reach) via ~/.tmux.conf — shown in section 08. This guide uses the default Ctrl-b throughout; translate to Ctrl-a if you remap.
04 — The Core Workflow: Detach & Reattach

The reason to use tmux over SSH. Start a named session, run something long, detach, and it keeps running on the server without you.

Start a named session
tmux new -s deploy

You're inside tmux now, with a status bar at the bottom. Start a long job, then detach — the session and its processes stay alive on the server.

Detach — leaves everything running
Press: Ctrl-b d
List sessions
tmux ls # deploy: 1 windows (created Wed ...) [80x24]
Reattach
tmux attach -t deploy # or the short form: tmux a -t deploy
✓  After Ctrl-b d you can close the terminal, drop SSH, or shut your laptop — the session lives on the server. Reconnect, tmux attach -t deploy, and you're back exactly where you left off.
Handy session commands
CommandDoes
tmux new -s nameNew named session
tmux lsList sessions
tmux attach -t nameReattach (short: tmux a -t name)
tmux new -As nameAttach if it exists, else create — the one-liner to always land in a session
tmux kill-session -t nameKill one session
tmux kill-serverKill every session at once
ℹ  Inside tmux, Ctrl-b s shows an interactive session picker, and Ctrl-b $ renames the current session. tmux new -As main in your shell profile is a popular way to always drop into a persistent session on login.
05 — Windows (Tabs)

A session holds multiple windows — full-screen workspaces, shown as tabs in the status bar and numbered from 0.

KeysAction
Ctrl-b cCreate a new window
Ctrl-b n / pNext / previous window
Ctrl-b 09Jump to window by number
Ctrl-b wInteractive window/session tree picker
Ctrl-b ,Rename the current window
Ctrl-b &Kill the current window (asks to confirm)
Ctrl-b fFind a window by name
ℹ  A common setup: window 0 an editor, window 1 a running dev server, window 2 a shell for git. Ctrl-b w gives you a navigable tree of all sessions and windows — the fastest way around once you have a few.
06 — Panes (Splits)

Where tmux shines: split a window into panes and see several shells at once. Unlike Screen, a new pane opens a shell immediately — no separate "put a window in the region" step.

KeysAction
Ctrl-b %Split vertically (left / right)
Ctrl-b "Split horizontally (top / bottom)
Ctrl-b ←↑↓→Move focus between panes with arrow keys
Ctrl-b oCycle to the next pane
Ctrl-b zZoom the focused pane to full window (toggle)
Ctrl-b SpaceCycle through preset layouts
Ctrl-b { / }Swap the focused pane left/up or right/down
Ctrl-b xKill the focused pane (asks to confirm)
Ctrl-b !Break the focused pane out into its own window
ℹ  Ctrl-b z (zoom) is the standout: temporarily blow one pane up to full size to focus, press again to restore the split. To resize panes, hold the prefix and tap arrow keys, or set up mouse mode (section 08) to drag borders.
07 — Scrollback & Copy Mode

tmux keeps its own scrollback per pane. Enter copy mode to scroll up and select text without a mouse.

KeysAction
Ctrl-b [Enter copy mode (then arrows / PgUp to scroll)
SpaceStart selection (emacs keys); v in vi mode
EnterCopy the selection and exit copy mode
Ctrl-b ]Paste the copied buffer
qQuit copy mode
Ctrl-b /Search in copy mode (newer versions)
⚠  By default the scrollback buffer is 2000 lines — small. Raise it with set -g history-limit 50000 in your config so copy mode can reach further back. Note this only applies to panes created after the setting loads.
08 — Configuration (~/.tmux.conf)

tmux reads ~/.tmux.conf at server start. This is where it goes from useful to comfortable — a sensible starter below. Reload it live with Ctrl-b : then source-file ~/.tmux.conf.

~/.tmux.conf starter
# Remap prefix to Ctrl-a (easier reach; frees Ctrl-b) unbind C-b set -g prefix C-a bind C-a send-prefix # More scrollback set -g history-limit 50000 # Mouse: click panes, drag borders, scroll set -g mouse on # Start windows & panes at 1, not 0 (matches the keyboard) set -g base-index 1 setw -g pane-base-index 1 # Split panes with | and - (and keep the current path) bind | split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}" # Reload config with prefix + r bind r source-file ~/.tmux.conf \; display "Config reloaded" # Faster key response; bigger colours set -sg escape-time 10 set -g default-terminal "tmux-256color"
ℹ  set -g mouse on is the single most quality-of-life line: click to focus a pane, drag borders to resize, scroll naturally. For plugins, the tmux Plugin Manager (tpm) adds things like session persistence across reboots (tmux-resurrect) — worth exploring once the basics are second nature.
09 — Quick Reference
Keys / CommandAction
Ctrl-b dDetach (leave running)
Ctrl-b cNew window
Ctrl-b n / pNext / previous window
Ctrl-b ,Rename window
Ctrl-b % / "Split vertical / horizontal
Ctrl-b arrowsMove between panes
Ctrl-b zZoom / unzoom pane
Ctrl-b [Scrollback / copy mode
Ctrl-b s / wSession / window picker
Ctrl-b ?List all key bindings
tmux new -s nameStart named session
tmux lsList sessions
tmux a -t nameReattach
tmux new -As nameAttach or create
✓  Lost? Ctrl-b ? lists every binding (q to exit). To leave tmux, exit each pane and window until the session ends — that terminates it, unlike detaching, which leaves it running.