tmux starters, one command per page
Thirty-two commands for developers who SSH into a server and lose work when the connection drops: sessions that survive the drop, the server behind it all, the prefix key, named sessions with new -s and new -A, detach and attach, windows and their numbers, split-window and panes, moving and resizing, layouts, copy mode, buffers, choose-tree, tmux.conf, and the TERM trap, one command per page.
A diagram, the classic trap, and one command to go try this week. That's a page.
tmux starters, one command per page
Thirty-two commands for developers who SSH into a server and lose work when the connection drops: sessions that survive the drop, the server behind it all, the prefix key, named sessions with new -s and new -A, detach and attach, windows and their numbers, split-window and panes, moving and resizing, layouts, copy mode, buffers, choose-tree, tmux.conf, and the TERM trap, one command per page.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
tmux behaviour checked against the tmux(1) manual page (man7.org Linux man-pages, tmux upstream of 2026-08), fetched and read during this build: DESCRIPTION; Default Key Bindings; Clients and Sessions; Windows and Panes; Options; Buffers; Environment; Files; Examples. Concepts are named as the manual names them. The one practice claim, spaced practice beats cramming, is Cepeda et al. 2006, Psychological Bulletin, a meta-analysis of 317 experiments (PubMed 16719566). Teaching conventions are named as conventions. This book quotes no verbatim passages and is an independent guide not affiliated with or endorsed by the tmux project or its authors.
General information only. Not professional advice; verify against your own tmux version and the current manual.
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
The model
What tmux is, the three-level tree of sessions, windows and panes, the server that outlives your connection, and the prefix key that commands everything.
- 01One screen, many terminals
- 02Sessions hold windows
- 03Sessions survive the drop
- 04A server behind it all
- 05The prefix key, C-b
tmux is a terminal multiplexer: it lets a number of terminals be created, accessed and controlled from a single screen. It may be detached from a screen and continue running in the background, then later reattached. A status line at the bottom shows session info. Per the tmux(1) manual, DESCRIPTION.
One screen, many terminals
Let's say you keep five SSH windows open because each one is one thing, and your window manager has opinions.
tmux enables a number of terminals to be created, accessed and controlled from a single screen, says the manual. Many terminals, one window, each doing its job. The bar along the bottom is the status line, and it's how you know where you are.
One screen. As many terminals as you want.
Type tmux this week, notice the status line appear, then type exit to leave. That's the whole loop.
A session is a single collection of pseudo terminals under the management of tmux. Each session has one or more windows linked to it. A window occupies the entire screen and may be split into rectangular panes, each a separate pseudo terminal. Per the tmux(1) manual, DESCRIPTION.
Sessions hold windows
Let's say someone says just attach to the session and you nod, having no picture behind the word.
Here's the picture. A session is a collection of pseudo terminals; each session has one or more windows; a window fills the screen and may be split into panes, each pane its own terminal. Session, windows, panes. Three levels, that's the whole tree.
Session holds windows. Windows split into panes.
Inside tmux this week, press C-b w and read the tree it shows: your session, its windows, their panes.
Each session is persistent and will survive accidental disconnection, such as an ssh connection timeout, or intentional detaching with the C-b d key strokes. tmux may be reattached using tmux attach. Per the tmux(1) manual, DESCRIPTION.
Sessions survive the drop
Let's say the train goes through a tunnel and the deploy dies with the SSH line. Again.
Each session is persistent and will survive accidental disconnection or intentional detaching with C-b d, says the manual. The session runs inside tmux on the server, not inside your connection. Reconnect, tmux attach, and it's all still there.
The session never lived in your connection.
This week: start tmux on a remote box, run top, kill your SSH client entirely, reconnect, and tmux attach to find top still running.
In tmux, a session is displayed on screen by a client, and all sessions are managed by a single server. The server and each client are separate processes which communicate through a socket in /tmp. Once all sessions are killed, tmux exits. Per the tmux(1) manual, DESCRIPTION.
A server behind it all
Let's say you close the laptop and the session survives, and nobody ever told you what was holding it.
All sessions are managed by a single server; clients and the server are separate processes talking through a socket in /tmp, says the manual. Your terminal is just a client, a window onto the server's sessions. Expecting the last window closed to stop the server is the leftover; sessions, not windows, are what keep it alive.
Clients come and go. The server stays.
Run ps aux this week and find the tmux server process while a session is detached. It's been holding your work the whole time.
tmux may be controlled from an attached client using a key combination of a prefix key, C-b (Ctrl-b) by default, followed by a command key. For example C-b c creates a new window, C-b d detaches the client. Per the tmux(1) manual, DEFAULT KEY BINDINGS and EXAMPLES.
The prefix key, C-b
Let's say you press C-b and nothing happens, and you conclude tmux is broken. It's listening.
tmux is controlled by a prefix key, C-b by default, followed by a command key, says the manual. It's a knock, then a request. C-b then c makes a window, C-b then d detaches. Holding C-b down like a modifier is the classic fumble; press, release, then the command key.
Knock first. Then ask.
This week, press C-b, release it, then press ? and read the key binding list. Press q to leave it.
The -A flag makes new-session behave like attach-session if the session name already exists. Per the tmux(1) manual, new-session. The attach-session command attaches to a target session which must already exist. Per the tmux(1) manual, CLIENTS AND SESSIONS.
new -A: make or attach
Let's say your morning routine is tmux ls, squint, then either new or attach. There's a flag for that.
-A makes new-session behave like attach-session if the name already exists, says the manual. tmux new -A -s work makes it if it's missing, attaches if it's not. Same keystrokes every morning, no squinting.
One command. Both cases. Habit formed.
Change your morning line to tmux new -A -s work this week and notice you stop thinking about it.
Once all sessions are killed, tmux exits; the exit-empty option, on by default, makes the server exit when there are no active sessions. Sessions, windows and panes are each numbered with a unique ID: sessions prefixed with $, windows with @, panes with %, unique and unchanged for the life of each. Per the tmux(1) manual, DESCRIPTION, OPTIONS and COMMANDS.
The whole machine
Let's say you got this far and the prefix still feels like a stranger sometimes.
It's a tree, and now you know it: a server holds sessions, sessions hold windows, windows split into panes, and each node carries an ID for life, says the manual. C-b w shows it, one command a day walks it. The spaced-practice line applies here too: a rep a day beats a binge a month.
Server, sessions, windows, panes. Say it until it's boring.
Teach the four-level tree to one workmate this week from memory. Teaching it is the last rep.