Multiplexing with tmux
Keep remote sessions alive and split your terminal into panes with tmux.
Theory
tmux is a terminal multiplexer: it runs persistent sessions that survive disconnects, and splits one terminal into multiple panes and windows. This solves two real problems:
- Persistence — start a long job over SSH, detach, and your session (and the job) keeps running. Reattach later from anywhere.
- Layout — watch logs in one pane while editing in another.
Everything is driven by a prefix key (default Ctrl+b) followed by a command
key. Detaching and reattaching is the killer feature for remote work.
Real-World Example
tmux new -s work # start a named session
# Ctrl+b % split vertically
# Ctrl+b " split horizontally
# Ctrl+b o switch panes
# Ctrl+b c new window
# Ctrl+b d detach (job keeps running)
tmux ls # list sessions
tmux attach -t work # reattach Hands-On Exercise
- Start a named tmux session, split it into two panes, and run a command in each.
- Start
topin tmux, detach, then reattach and confirm it’s still running. - Create a second window and switch between windows.
- Explain how tmux helps when an SSH connection is unreliable.
Cheat Sheet▾
| Action | Keys (after Ctrl+b) |
|---|---|
| New session | tmux new -s name |
| Split vertical / horizontal | % / " |
| Move between panes | o or arrow keys |
| New window | c |
| Next / previous window | n / p |
| Detach | d |
| List / attach | tmux ls / tmux attach -t name |
Common Interview Questions▾
What problem does tmux solve for remote work?
It keeps sessions alive independently of your connection — a long job started in tmux survives an SSH disconnect, and you can reattach later from anywhere.
What's the difference between a window and a pane in tmux?
A window is like a tab (full-screen view); a pane is a split region within a window. One session has many windows, each with one or more panes.
Official Documentation
📝 My notes on this topic
Auto-saves as you type