Multiplexing with tmux

💤0
Lv 10 XP
← 🧱 Foundations · Command Line Skills

Multiplexing with tmux

Intermediate ⭐ 80 XP ⏱ 15 min #cli#tmux#productivity

Keep remote sessions alive and split your terminal into panes with tmux.

📖Theory

tmux is a terminal multiplexer: it runs persistent sessions that survive disconnects, and splits one terminal into multiple panes and windows. This solves two real problems:

  • Persistence — start a long job over SSH, detach, and your session (and the job) keeps running. Reattach later from anywhere.
  • Layout — watch logs in one pane while editing in another.

Everything is driven by a prefix key (default Ctrl+b) followed by a command key. Detaching and reattaching is the killer feature for remote work.

🌍Real-World Example
tmux new -s work          # start a named session
# Ctrl+b %   split vertically
# Ctrl+b "   split horizontally
# Ctrl+b o   switch panes
# Ctrl+b c   new window
# Ctrl+b d   detach (job keeps running)

tmux ls                   # list sessions
tmux attach -t work       # reattach
✍️Hands-On Exercise
  1. Start a named tmux session, split it into two panes, and run a command in each.
  2. Start top in tmux, detach, then reattach and confirm it’s still running.
  3. Create a second window and switch between windows.
  4. Explain how tmux helps when an SSH connection is unreliable.
🧾Cheat Sheet
ActionKeys (after Ctrl+b)
New sessiontmux new -s name
Split vertical / horizontal% / "
Move between paneso or arrow keys
New windowc
Next / previous windown / p
Detachd
List / attachtmux ls / tmux attach -t name
💬Common Interview Questions
What problem does tmux solve for remote work?

It keeps sessions alive independently of your connection — a long job started in tmux survives an SSH disconnect, and you can reattach later from anywhere.

What's the difference between a window and a pane in tmux?

A window is like a tab (full-screen view); a pane is a split region within a window. One session has many windows, each with one or more panes.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type