Skip to content
daniel@MacBookPro:~
Shell & TerminalHow-To September 13, 2026 3 min read

How to Set Up and Use tmux for Terminal Multiplexing

A complete walkthrough running multiple shell sessions inside one terminal window, splitting panes, and — most importantly — keeping sessions alive across disconnects.

tmux (terminal multiplexer) lets you run multiple shell sessions inside a single terminal window, organized into windows and panes, and — critically — keeps those sessions running even if your terminal disconnects entirely.

Step 1: install tmux

# Debian/Ubuntu
sudo apt install tmux

# macOS (Homebrew)
brew install tmux

# FreeBSD
pkg install tmux

Step 2: start a new named session

tmux new -s work

Naming your session (work, in this example) makes it easy to identify and reattach to later, rather than relying on tmux’s default numeric session IDs.

Step 3: understand the prefix key

Ctrl-b   (tmux's default prefix)

Almost every tmux command is triggered by pressing the prefix key first, then a follow-up key — covered in more depth in this blog’s dedicated tmux keybinding troubleshooting post if you run into conflicts with other applications.

Step 4: split your window into panes

Ctrl-b then %   (split vertically)
Ctrl-b then "   (split horizontally)
Ctrl-b then arrow key   (move between panes)

Panes let you view and interact with multiple shells simultaneously within one window, without needing multiple separate terminal windows.

Step 5: create additional windows within the same session

Ctrl-b then c    (create a new window)
Ctrl-b then n    (next window)
Ctrl-b then p    (previous window)
Ctrl-b then 0-9  (jump directly to window number)

Windows function like tabs — each holds its own layout of one or more panes, useful for keeping logically separate tasks visually separated within the same tmux session.

Step 6: detach from a session without ending it

Ctrl-b then d

Detaching leaves the entire session — every running process inside it — alive in the background, while returning your terminal to its normal state outside tmux.

Step 7: reattach to a running session, including after a disconnect

tmux attach -t work

This is tmux’s single most valuable capability: a session started over SSH survives a dropped connection, a closed laptop lid, or a deliberate detach entirely — reattaching from anywhere picks up exactly where you left off, including any long-running process still executing inside it.

Step 8: list all currently running sessions

tmux ls

Useful when you have multiple named sessions running and need to confirm which ones are still active before reattaching to a specific one.

Step 9: customize tmux via its configuration file

~/.tmux.conf

Common customizations include remapping the prefix key, enabling mouse support (set -g mouse on), and adjusting the status bar’s appearance — changes take effect after tmux source-file ~/.tmux.conf or restarting tmux entirely.

Why tmux’s session persistence is the actual killer feature

Running a long build, a long-lived monitoring command, or simply wanting your exact terminal layout to survive a network hiccup are all solved by the same underlying tmux capability — a session existing independently of any specific terminal connection to it, which is a fundamentally different guarantee than a normal shell session provides on its own.