What are tmux sessions, windows, and panes, and how do they relate?
Updated
tmux organizes your terminal work in three nested levels: a session is the top-level workspace you can detach from and reattach to later; windows live inside a session and behave like tabs; panes split a single window so several terminals share the screen at once. The reference site tmuxcheatsheet.com mirrors this hierarchy directly — its command groups are Sessions, Windows, Panes, Copy Mode, and Misc — so once you understand the nesting, you know where to look up any command.
The three levels, from outermost to innermost
Session: the persistent workspace
A session is the container everything else lives in, and it is the unit that survives disconnection. You start one with tmux new (or tmux new -s mysession to name it), and you can leave it running in the background with Ctrl + b d. Later, tmux attach (or tmux a -t mysession) brings it back exactly as you left it.
The cheat sheet also lists tmux new-session -A -s mysession, which starts a session with that name or attaches to it if it already exists — useful when you want "open my workspace" to be one command whether or not it is already running. Cleanup commands sit at this level too: tmux kill-session -t mysession removes one session, and tmux kill-session -a removes all sessions except the current one.
Window: a tab inside a session
Each session holds one or more windows, and each window fills the terminal screen. Think of them as tabs: Ctrl + b c creates a window, Ctrl + b n and Ctrl + b p move to the next and previous one, and Ctrl + b 0 through Ctrl + b 9 jump directly by number. Ctrl + b w lists windows, and Ctrl + b , renames the current one.
You can also create a session and its first named window in one step: tmux new -s mysession -n mywindow. Windows can be reordered or moved between sessions with commands like swap-window and move-window, which the cheat sheet documents under Windows.
Pane: splitting a window
A pane is a subdivision of a window, letting you watch several terminals simultaneously. Ctrl + b % splits the current pane with a vertical line (side-by-side layout), and Ctrl + b " splits with a horizontal line (stacked layout). Ctrl + b ; toggles back to the last active pane.
Panes are not a separate workspace — they belong to the window that was split. The cheat sheet notes that join-pane can merge two windows into panes of one window, which shows the relationship in reverse: windows and panes are both views onto running terminal processes, and tmux lets you rearrange them.
How the levels fit together
| Level | Created with | Typical role | Detach/reattach? |
|---|---|---|---|
| Session | tmux new -s name |
Whole workspace, survives disconnect | Yes — Ctrl + b d, then tmux attach |
| Window | Ctrl + b c |
Tab within a session | No — lives and dies with its session |
| Pane | Ctrl + b % or Ctrl + b " |
Split view inside one window | No — belongs to its window |
The nesting rule is simple: one session contains many windows; one window contains many panes. Detaching affects the session as a whole, so every window and pane inside it keeps running. Killing a session removes everything beneath it.
Why the cheat sheet's grouping matters
Because the site organizes commands by these three levels, the fastest way to find a command is to ask which level it acts on. Renaming, listing, and killing are session-level operations found under Sessions. Creating, switching, and reordering tabs are under Windows. Splitting and joining are under Panes. Copy Mode and Misc cover behavior that applies across levels, such as scrollback and configuration.
A practical example: if you want to check on a long-running build while editing code, keep the build in one window, open a second window for the editor, and split that editor window into two panes — logs on one side, code on the other. Detach with Ctrl + b d when you leave, and tmux attach restores the entire arrangement.