If your SSH connection drops, programs started in that session stop with it. tmux keeps your terminal alive on the server: you start a session, leave it running and come back later from anywhere. It is ideal for long downloads, builds, imports and anything you want to watch. If you are logged in as root, leave out sudo.
sudo apt install -y tmux # Debian, Ubuntu
sudo dnf install -y tmux # AlmaLinux, Rockytmux new -s work # start a session named work
# run your command, then press Ctrl+b and then d to detach
tmux ls # list sessions
tmux attach -t work # come back to it
tmux kill-session -t work # end the session and everything running in it
When you detach, everything keeps running. After a dropped connection, log in again and run tmux attach -t work.
All keys start with Ctrl+b, then:
d detach, c new window, n next window, , rename window.% split side by side, " split top and bottom, arrow keys move between panes.[ scroll mode (use the arrow keys or Page Up, press q to leave).nohup command & also survives a disconnect, but you cannot reattach to it.More basics: first login · checking resources · Fast VPS
Why does my command stop when SSH disconnects?
Programs started in the SSH session end with it. Run them inside tmux (or as a service) so they keep running.
How do I leave tmux without stopping my command?
Press Ctrl+b and then d to detach; the session and your command keep running.
How do I get back to my session?
Log in again and run tmux attach -t NAME; tmux ls lists the sessions.
Does tmux survive a reboot?
No. For something that must always run, make it a systemd service.