tmux is a terminal multiplexer for Unix-like systems that allows multiple terminal sessions to run simultaneously within a single window, with sessions persisting even after disconnection. It enables detachable sessions that survive SSH drops, system reboots (with plugins), and accidental terminal closures — making it invaluable for remote work, long-running processes, and complex multi-pane workflows. The key mental model: sessions contain windows, windows contain panes — each layer offers progressively finer control over your terminal workspace, with the prefix key (Ctrl+b by default) serving as the gateway to all tmux commands.
What This Cheat Sheet Covers
This topic spans 19 focused tables and 161 indexed concepts, 101 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Session Management
Sessions are the outermost layer of tmux — a self-contained workspace that keeps running on the server even after you disconnect. These are the commands you reach for to create, name, attach to, and tear down those sessions, which is exactly what makes tmux survive a dropped SSH connection. Get comfortable with new, attach, and detach first; everything else falls into place once that reattach loop clicks.
| Command | Example | Description | |
|---|---|---|---|
tmux new -s work | • Creates a new named session • sessions persist after disconnection and can be reattached later | ||
tmux attach -t work | • Attaches to an existing session by name or ID • reconnects to your work exactly where you left off | ||
Ctrl+b d | • Detaches from the current session • session continues running in the background | ||
tmux ls | Lists all active sessions with their names, window count, and creation time. | ||
tmux kill-session -t work | • Terminates a specific session and all its windows and panes • cannot be recovered | ||
Ctrl+b $tmux rename-session -t old new | • Renames the current session • helps organize multiple projects with meaningful names | ||
Ctrl+b stmux switch-client -t work | • Switches between sessions • Ctrl+b s shows an interactive session tree for selection | ||
tmux new -d -s background | Creates a detached session that starts running immediately without attaching to it. | ||
tmux attach -d -t work | • Attaches and detaches others • forces other clients to disconnect from the same session | ||
tmux has-session -t work | • Checks if a session exists • returns exit code 0 if found, useful in scripts |