sudo apt install tmux
tmux- Starts a new tmux session.
- Even if SSH disconnects, the session keeps running in the background.
- Run all upgrade commands inside tmux.
- If SSH disconnects, log back in and reattach:
tmux attach| Action | Keys |
|---|---|
| Detach from session (leave it running) | Ctrl+b then d |
| List sessions | tmux ls |
| Attach to last session | tmux attach |
| Attach to specific session | tmux attach -t SESSION_NAME |
| Create new named session | tmux new -s mysession |
| Kill current session | type exit |
| Kill a session from outside | tmux kill-session -t SESSION_NAME |
| Rename current session | Ctrl+b then $ |
| Scroll output mode | Ctrl+b then [ (exit with q) |
| Split window vertically | Ctrl+b then % |
| Split window horizontally | Ctrl+b then " |
| Switch panes | Ctrl+b then Arrow keys |
- Start a named tmux session:
tmux new -s upgrade- Run your upgrade commands inside:
sudo apt update
sudo apt upgrade --without-new-pkgs
sudo apt full-upgrade- Detach if needed:
- Press
Ctrl+bthend
- Press
- Reattach later:
ssh user@server
tmux attach -t upgrade- Name sessions for easy reattachment.
- Multiple sessions can run simultaneously.
- Detaching and reattaching resets your layout view.