Skip to main content

What is Tmux

Tmux is a terminal multiplexer. It lets you open multiple terminal sessions inside a single window, organize them into windows and panes, and most importantly — detach and reattach without losing your work.

Learning Focus

Use this lesson to understand tmux's mental model (server, sessions, windows, panes) so you can use it confidently in production server work.

Core Idea

Tmux runs as a background server. Your terminal is just a client connecting to it. When you disconnect, the server keeps running — your sessions are safe.

The Problem Tmux Solves

Without tmux:

With tmux:

How Tmux Is Structured

LayerWhat it isAnalogy
ServerBackground tmux daemonApp server
SessionNamed workspace groupBrowser profile
WindowA tab inside a sessionBrowser tab
PaneA split inside a windowSplit editor view

Why Operators Use Tmux

NeedTmux capabilityPractical effect
SSH safetySessions survive disconnectsLong jobs never get killed
Multi-taskingWindows + panesEditor, logs, shell — all visible
Remote collaborationShared sessionsTwo people in same session
AutomationScript-driven layoutsPre-built dev/ops dashboards
MonitoringTiled pane layoutHtop, logs, app status — side by side

Tmux vs Screen vs SSH Alone

FeatureTmuxScreenSSH alone
Persistent sessions
Multiple windows
Pane splittingLimited
Scriptable layouts
Status bar✅ customizableBasic
Plugin ecosystem✅ (TPM)
Active developmentMinimal
tip

In 2024+, tmux is the standard choice. Use screen only when tmux is unavailable.

The Prefix Key

Every tmux command starts with a prefix key combination (default: Ctrl+b), followed by another key.

Default ShortcutModification ShortcutAction
Ctrl+b dCtrl+Space dDetach from session
Ctrl+b cCtrl+Space WCreate new window
Ctrl+b %`Ctrl+Space`
Ctrl+b "Ctrl+Space -Split pane horizontally
warning

You must press and release Ctrl+b before pressing the second key. Do not hold all keys at once.

Basic Commands Overview

# start a named session
tmux new-session -s mywork

# list all sessions
tmux ls

# attach to a session
tmux attach -t mywork

# kill a session
tmux kill-session -t mywork

Common Mistakes (Beginners)

MistakeWhat happensFix
Closing terminal instead of detachingSession is killedAlways use Ctrl+b d to detach
Forgetting to name sessionsHard to find the right oneAlways use -s name
Nesting tmux inside tmuxPrefix confusionBe aware of nesting; use distinct configs
Using exit in all panesKills the window/sessionJust close the pane, not the session

Hands-On Practice

Try this on any Linux machine with tmux installed:

# start a session and run something
tmux new-session -s lab
top

# press Ctrl+b, then d to detach
# verify the session is still running
tmux ls

# reattach
tmux attach -t lab

# exit top, then kill the session
tmux kill-session -t lab

What's Next