tmux for dummies

the one use case that matters: your SSH connection dies, your work doesn't.

the problem

you SSH into a server, start something long-running, your wifi drops (or laptop sleeps) → process killed, work gone.

the fix

# 1. on the server, start a session
tmux

# 2. do your work as usual
./long_running_thing.sh

# 3. connection dies? no problem. reconnect via SSH, then:
tmux attach

# your session is exactly where you left it.

detach on purpose

leave the session running and go home:

Ctrl-b  d      # detach (session keeps running on the server)

Ctrl-b is the "prefix": press Ctrl-b, release, then press the next key.

minimal survival kit

tmuxstart a new session
tmux new -s workstart a named session called "work"
tmux lslist running sessions
tmux attachreattach to the last session
tmux attach -t workreattach to the session named "work"
Ctrl-b ddetach (leave it running)
exitend the session for good (type it in the shell)

typical day

ssh user@server
tmux attach || tmux new -s work   # reattach if it exists, else create
# ... work ...
Ctrl-b d                          # or just close your laptop lid