← All 51 books tmux starters, one command per page Get the full edition · £10
One command per 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.


Steve Hodgkiss 7 commands

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

Contents


Part 1 · The model4
One screen, many terminals5
Sessions hold windows6
Sessions survive the drop7
A server behind it all8
The prefix key, C-b9
Part 2 · Sessions
new -A: make or attach10
Part 3 · Owning it
The whole machine11
Part 1 of 3
Multiplexer, server, prefix
1

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.


In this part
  1. 01One screen, many terminals
  2. 02Sessions hold windows
  3. 03Sessions survive the drop
  4. 04A server behind it all
  5. 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.

tmux starters · No. 01
Start here

One screen, many terminals

tmux is a terminal multiplexer

ONE SCREEN, MANY TERMINALSterminaltmuxterminal 1editorterminal 2logsterminal 3deployone status line,shared knowledgedetached, it keeps runningmany terminals, created and controlled from one screen

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.

TRY THIS WEEK

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.

tmux starters · No. 02
Start here

Sessions hold windows

Windows split into panes: the whole tree

SESSIONS HOLD WINDOWSsession0 editor1 logs2 deploytail -f app.loggrep errwindows fill the screen; a window splits into paneseach paneits own pseudo terminalsession to windows to panes: three levels, that's the tree

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.

TRY THIS WEEK

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.

tmux starters · No. 03
Start here

Sessions survive the drop

The SSH line dies, the work doesn't

SESSIONS SURVIVE THE DROPlaptopSSH clientserverdeploylogsthe build keeps runningSSH line diestunnel, wifi, train:the connection, not the workthe session never lived in the connection

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.

TRY THIS WEEK

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.

tmux starters · No. 04
Start here

A server behind it all

Clients attach; the server holds sessions

A SERVER BEHIND IT ALLtmux serversession deploysession logssocket in /tmpclient 1your terminalclient 2another terminalclients come and go; sessions stayyour terminal is a window onto the server, nothing more

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.

TRY THIS WEEK

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.

tmux starters · No. 05
Start here

The prefix key, C-b

Every command starts with the same knock

THE PREFIX KEY, C-BC-bcommandpress, release,then the command keycnew windowddetach[copy modeone knockthen the requestprefix first, release, then the command key

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.

TRY THIS WEEK

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.

tmux starters · No. 06
Sessions

new -A: make or attach

One flag, the honest default

NEW -A: MAKE OR ATTACHtmux new -A -s deployexists?yesattachnocreateone command,both casessame keystrokes every morning, no squinting at tmux ls

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.

TRY THIS WEEK

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.

tmux starters · No. 07
The long game

The whole machine

One command a day, sessions for years

THE WHOLE MACHINEtmux serversocket in /tmpdeploylogseditorinfradb$3@12%51IDs for life: $ sessions, @ windows, % panesone command a day, the machine becomes yours

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.

TRY THIS WEEK

Teach the four-level tree to one workmate this week from memory. Teaching it is the last rep.

Index

Index


A server behind it all8
new -A: make or attach10
One screen, many terminals5
Sessions hold windows6
Sessions survive the drop7
The prefix key, C-b9
The whole machine11