deliberate.codes

Weblog of Marco N. - a software guy in data. I build with AI.

tmux essentials for persistent terminal sessions

tmux keeps your terminal sessions alive when you disconnect.

Install#

# macOS
brew install tmux

# Ubuntu/Debian
sudo apt install tmux

Core concepts#

  • Session: A collection of windows, persists after disconnect
  • Window: A full-screen tab within a session
  • Pane: A split within a window

Essential commands#

All tmux commands start with the prefix Ctrl+b, then a key.

ActionCommand
New sessiontmux new -s myproject
DetachCtrl+b d
List sessionstmux ls
Attachtmux attach -t myproject
Kill sessiontmux kill-session -t myproject

Window management#

ActionCommand
New windowCtrl+b c
Next windowCtrl+b n
Previous windowCtrl+b p
Rename windowCtrl+b ,

Pane splitting#

ActionCommand
Split verticalCtrl+b %
Split horizontalCtrl+b "
Navigate panesCtrl+b arrow
Close paneCtrl+d or exit

Typical workflow#

# Start a named session
tmux new -s dev

# Run your process (e.g., a build server)
npm run dev

# Detach with Ctrl+b d
# Log out, go home, whatever

# Later, reattach
tmux attach -t dev
# Your process is still running