How Does tmux Work?
Session Persistence & Splitting with a Terminal Multiplexer
tmux (terminal multiplexer) is a tool that manages multiple sessions in a single terminal window, splits panes, and maintains work even when SSH connections drop. The key is its server-client architecture. The tmux server manages sessions in the background, and the terminal we see connects to the server as a client. So even when you close the terminal (detach), the server session stays alive and you can reconnect (attach) later. The hierarchy is Server > Session > Window > Pane.
Architecture Diagram
- Server-Client Architecture: Terminal is the client, tmux server runs in the background
- Session Persistence: Server+session stays alive after detach โ safe from SSH disconnection
- Multiple Connections: Multiple clients can attach to the same session (pair programming)
- Screen Splitting: Split a Window into Panes for multitasking
How It Works
tmux server process starts in background on first tmux command
Server creates new Session, with a default Window inside the session
Terminal (client) connects to server and displays session
Ctrl+b d to detach โ only client terminates, server+session persists
tmux attach to reconnect to existing session (even after SSH reconnection)
Ctrl+b %/" to split panes, Ctrl+b c to create new window
Pros
- ✓ Session persists despite SSH disconnection
- ✓ Multitasking via screen splitting
- ✓ Collaboration via session sharing
- ✓ Automatable via scripts (tmuxinator)
- ✓ Lightweight and fast
Cons
- ✗ Key binding learning curve
- ✗ Getting used to prefix key (Ctrl+b)
- ✗ Limited mouse support (configuration needed)
- ✗ Difficult to manage complex layouts