When to use tmux
Use tmux to maintain server-side terminal sessions while moving between SSH connections. It helps preserve an interactive workspace, but does not replace backups, service supervision or a reliable server.
Syntax
tmux [COMMAND]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Create a work session
tmux new -s maintenanceA named session is created on the server under the current account.
Show your sessions
tmux lsExisting sessions on the selected tmux server are listed.
Return to session
tmux attach -t maintenanceThe selected session is attached so work can continue from another connection.
Notes and limitations
- Detach with Ctrl+B, then D. The session normally keeps running after SSH disconnects.
- tmux preserves an interactive session; use systemd when a service must start after reboot.
Common questions and troubleshooting
How do I leave tmux without closing my work?
The usual default is Ctrl+B followed by D to detach. Reattach after reconnecting to the same server and account.
Why is my session missing after reconnecting?
Check host, user and tmux socket. The server may have rebooted, the session may have exited or a different socket may be selected.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man tmux.