Skip to content

Instantly share code, notes, and snippets.

@ngoc-minh-do
Last active August 10, 2025 14:35
Show Gist options
  • Select an option

  • Save ngoc-minh-do/7594522ed33ea054d9b3c9adc79b57ab to your computer and use it in GitHub Desktop.

Select an option

Save ngoc-minh-do/7594522ed33ea054d9b3c9adc79b57ab to your computer and use it in GitHub Desktop.

Tmux Quick Reference Guide

1. Install & Start Tmux

sudo apt install tmux
tmux
  • Starts a new tmux session.
  • Even if SSH disconnects, the session keeps running in the background.

2. Basic Workflow

  • Run all upgrade commands inside tmux.
  • If SSH disconnects, log back in and reattach:
tmux attach

3. Common Commands

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

4. Best Practice for Server Upgrades

  1. Start a named tmux session:
tmux new -s upgrade
  1. Run your upgrade commands inside:
sudo apt update
sudo apt upgrade --without-new-pkgs
sudo apt full-upgrade
  1. Detach if needed:
    • Press Ctrl+b then d
  2. Reattach later:
ssh user@server
tmux attach -t upgrade

5. Tips

  • Name sessions for easy reattachment.
  • Multiple sessions can run simultaneously.
  • Detaching and reattaching resets your layout view.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment