Immortal Sessions
When you SSH into a server and run a long-running process — a database migration, a build, a log tail — your process is a child of your SSH session. If your network drops, your laptop battery dies, or you simply close the terminal window, the SSH session ends. The OS sends a SIGHUP (hangup signal) to every process in that session, and they terminate.
tmux decouples your processes from your network connection.
tmux (Terminal Multiplexer) runs a server process on the remote machine, entirely separate from any single SSH connection. Your shell and everything it launches live inside a session managed by that server; the SSH connection you're typing into is just a view into that session, not the session itself. You start a session, run whatever long-running process you need inside it, and then detach — which leaves the session, and everything running inside it, alive on the server while your terminal returns to normal. Reattaching later, whether from the same machine or a brand-new SSH connection, drops you straight back into that session exactly as you left it, scrollback and all.
This is precisely the mechanism that lets a multi-hour migration or deployment survive a dropped VPN, a closed laptop lid, or a flaky network connection: the process was never a child of your SSH session to begin with, so nothing about that connection dying ever reaches it. tmux sessions also support multiple windows and split panes within a single session, so one persistent session can hold several parallel views of a job — a log tail in one pane, the running process in another — that all detach and reattach together as a unit.
Essential tmux keyboard shortcuts
Every tmux command is triggered by a two-key sequence: a configurable prefix key (Ctrl+B by default), followed by a command key. The prefix's only job is disambiguation — it tells tmux "the next keystroke is a command for me, not input for whatever program is running inside the session." Without it, tmux would have no way to distinguish a d you meant to detach with from a d you meant to type into your shell.
| Shortcut | Action |
|---|---|
Ctrl+B d |
Detach from session (session keeps running) |
Ctrl+B c |
Create a new window (like a new tab) |
Ctrl+B n |
Next window |
Ctrl+B p |
Previous window |
Ctrl+B % |
Split pane vertically (side by side) |
Ctrl+B " |
Split pane horizontally (top and bottom) |
Ctrl+B arrow |
Move between panes |
Ctrl+B [ |
Enter scroll mode (use arrow keys; q to exit) |
Why not just use nohup or &?
nohup command & runs a command immune to hangups in the background. It works for fire-and-forget tasks, but you lose interactivity — you cannot attach to it, see its live output, or send it input. tmux gives you a fully interactive session that persists. For operational work on servers, tmux is the right tool.
A common SRE interview scenario: "You're running a critical database migration on a production server over SSH. How do you ensure it completes even if your connection drops?" The expected answer is tmux (or screen). Bonus points for mentioning that you would also redirect output to a log file (./migrate.sh | tee migration.log) so you have a record even if you miss live output, and that you would monitor progress by reattaching periodically rather than leaving it completely unattended.