Day 44beginnerMar 16, 2026

Keep Terminal Sessions Alive with tmux

tmux keeps your terminal sessions running even when you disconnect — no more lost work from dropped SSH connections.

linuxterminalproductivity
Share:

What

tmux is a terminal multiplexer that lets you create persistent sessions that survive disconnections. You can detach from a session and reattach later, even from a different machine. It also lets you split your terminal into multiple panes and windows within a single connection.

Why It Matters

SSH connections drop, laptops close, and networks hiccup. Without tmux, a disconnection kills your running processes and you lose everything. With tmux, your long-running deploys, log tails, and editing sessions persist safely on the server regardless of your connection.

Example

# Create a new named session
tmux new -s deploy

# Detach from current session (keeps it running)
# Press: Ctrl+b, then d

# List all running sessions
tmux ls

# Reattach to a named session
tmux attach -t deploy

# Split pane horizontally
# Press: Ctrl+b, then "

# Split pane vertically
# Press: Ctrl+b, then %

# Switch between panes
# Press: Ctrl+b, then arrow key

# Kill a session when done
tmux kill-session -t deploy
bash

Common Mistake

Running long processes directly in the terminal instead of inside a tmux session. Without tmux, closing the terminal or losing your SSH connection kills all running processes. Always start a tmux session first, then run your commands inside it.

Quick Fix

Always start a tmux session before running long tasks: tmux new -s deploy. Use Ctrl+b then d to detach — the session keeps running in the background. Reconnect anytime with tmux attach -t deploy, even from a different machine.

Key Takeaways

  • 1tmux new -s name — create a named session for easy reattachment
  • 2Ctrl+b then d — detach (session stays alive in background)
  • 3tmux attach -t name — reattach from anywhere, even a different machine
  • 4Ctrl+b then " or % — split into horizontal or vertical panes
  • 5Never close the terminal — always detach to keep sessions alive

Was this tip helpful?

Help us improve the DevOpsPath daily collection

Share: