C.W.K.
Stream
Lesson 06 of 10 · published

tmux Essentials

~13 min · tmux, session, persistence

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

The terminal multiplexer

tmux lets one terminal hold multiple windows and panes, and — crucially — keeps them alive when you disconnect. SSH into a server, start a tmux session, run a long job, close your laptop, come back tomorrow, reattach, see the same screen.

The mental model

  • Server — one tmux daemon per user.
  • Session — a named workspace. Survives client disconnect.
  • Window — like a tab. Multiple per session.
  • Pane — a split inside a window.

The prefix key

Default prefix is Ctrl+B. Every tmux command starts with the prefix, then a key. Many people remap to Ctrl+A (GNU Screen muscle memory) — add set -g prefix C-a; unbind C-b to ~/.tmux.conf.

Daily commands

  • tmux new -s work — new session named work.
  • Ctrl+B d — detach. Session keeps running.
  • tmux ls — list sessions.
  • tmux attach -t work — reattach.
  • Ctrl+B c — new window.
  • Ctrl+B n / p — next / previous window.
  • Ctrl+B 0..9 — jump to window N.
  • Ctrl+B % — split pane vertically.
  • Ctrl+B " — split pane horizontally.
  • Ctrl+B arrow — move between panes.
  • Ctrl+B z — zoom into the current pane (toggle).
  • Ctrl+B [ — copy mode (vi keys to scroll/search).

Persistent dev environment

tmuxinator or smug save/restore named session layouts. tmux-resurrect persists across reboots. Many engineers ssh into a box, attach to a long-lived tmux session, and never "open a terminal" in the modern sense.

Code

Useful tmux config snippets·tmux
# ~/.tmux.conf
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set -g mouse on
set -g history-limit 50000
setw -g mode-keys vi
First-time tmux flow·bash
tmux new -s pippa
# inside tmux:
#   Ctrl+B c  → new window
#   Ctrl+B %  → split vertical
#   Ctrl+B "  → split horizontal
#   Ctrl+B d  → detach
tmux ls
tmux attach -t pippa

External links

Exercise

brew install tmux. tmux new -s test. Inside: Ctrl+B c for a new window, Ctrl+B % to split, Ctrl+B d to detach. From outside: tmux ls, tmux attach -t test. Add the .tmux.conf snippet.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.