Linux & Systems

tmux for a Quietly Persistent Shell

A small tmux routine for keeping remote work alive without turning the terminal into a cockpit.

2 min read
#tmux#terminal#ssh#productivity

A misty mountain lake emerging from a dark forest

Photo: Unsplash.

I ignored tmux for years because every introduction seemed to begin with a wall of key bindings. What I actually needed was much smaller: a command could continue when Wi-Fi disappeared, and I could return to the same shell later.

Create a named session:

tmux new -s maintenance

Run the long command inside it. To leave the session running, press Ctrl-b, release both keys, then press d. That sequence detaches the current client; it does not stop the shell or the process inside it.

List what remains:

tmux ls

Return by name:

tmux attach -t maintenance

Those three commands cover most of my remote-server use. A named session is easier to recognize than a generated number, especially after opening several SSH connections during an incident.

A few additions that earn their place

Create a new window with Ctrl-b c, move between windows with Ctrl-b n and Ctrl-b p, and scroll through old output with Ctrl-b [ followed by the usual arrow or page keys. Press q to leave copy mode.

When a session has done its job, close the shells normally or remove it explicitly:

tmux kill-session -t maintenance

tmux survives a broken SSH connection, but it is not a reboot-persistence system. If the server restarts, the tmux server and its sessions disappear too. Long-running services still belong in systemd, a container runtime, or another service manager with logs and a declared restart policy.

The useful mental model is simple: tmux keeps terminals on the remote machine and lets clients come and go. That is enough to make a train tunnel, a sleeping laptop, or a router restart much less dramatic.

Reference