How to use tmux: install, sessions, windows, panes, detach and attach

Install tmux, run sessions with windows and panes, detach while work continues, attach anytime.

Long jobs over SSH or a dozen terminal tabs — close the window and the process dies. tmux is a terminal multiplexer: multiple windows and panes inside one connection, detach while work keeps running, attach again anytime.

People searching how to install and use tmux sessions windows panes want a checkable path: install, create a session, split panes, detach/attach, and a minimal config. Steps follow man tmux and the upstream tmux wiki.

Install tmux Sessions and splits Detach / attach

What tmux is for

01

Sessions survive disconnects

Press Ctrl+b then d to detach. Builds, log tails, and migrations keep running when SSH drops.

02

Windows and panes on one screen

Windows act like tabs; each window splits into left/right or top/bottom panes so you can watch logs beside a shell.

03

Named, scriptable sessions

tmux new -s deploy names a session; tmux ls lists; tmux attach -t deploy returns. Common on shared jump hosts.

Install on macOS and Linux

  1. 1

    macOS: Homebrew

    Run brew install tmux and confirm with tmux -V. Apple Silicon and Intel use the same formula.

  2. 2

    Debian / Ubuntu

    sudo apt update && sudo apt install tmux. LTS packages may be older but fine for daily use; check distro docs for newer builds.

  3. 3

    Fedora / Arch

    Fedora: sudo dnf install tmux. Arch: sudo pacman -S tmux. Typing tmux starts a new session with a status bar.

  4. 4

    First run and exit

    Plain tmux creates a numbered session. To end it, exit every pane or run tmux kill-session. To leave temporarily, detach — do not just close SSH.

Sessions: create, list, attach

Hierarchy: server → session → window → pane. These commands work outside tmux too:

tmux new -s dev
tmux ls
tmux attach -t dev    # or: tmux a -t dev

# Inside a session: detach (processes keep running)
# Keys: Ctrl+b then d

On tmux 3.2+, tmux new -s foo -A attaches if foo already exists instead of erroring.

Windows and panes: prefix Ctrl+b

Press the prefix (default Ctrl+b), then the command key.

After prefixActionUse case
cNew windowFresh shell line
n / pNext / previous windowSwitch tabs
0–9Jump to windowStatus bar index
%Split left/rightLogs + shell
"Split top/bottomMonitor + edit
Arrow keysMove between panesMulti-pane work
xClose paneConfirm y/n
dDetach sessionBefore SSH drops
?Shortcut listWhen you forget keys

Starter config ~/.tmux.conf

set -g mouse on
set -g history-limit 50000
set -g base-index 1
setw -g pane-base-index 1
set -g default-terminal "tmux-256color"

Reload with tmux source-file ~/.tmux.conf. Full options: man tmux OPTIONS section.

tmux is not a shell — it manages terminal sessions. bash/zsh/fish still run inside panes; tmux handles windows and reconnects.

attach: no sessions
Session was killed or the server restarted. Check tmux ls.
Broken colors
Verify TERM, default-terminal, and UTF-8 locale on SSH host and client.
vim inside tmux
Prefix keys can clash with vim bindings. Consider setw -g mode-keys vi or plugins like vim-tmux-navigator per their docs.

For whiteboard or voice sync, open a browser room from the wbroom homepage — create and join a room.

Questions worth checking

tmux vs GNU screen?

Both multiplex terminals. tmux has a cleaner window/pane model and consistent scripting; screen still works with screen -S / screen -r on older systems.

Auto-start a session on login?

Use systemd, a guarded line in .bashrc like tmux attach -t main || tmux new -s main, or your deploy recipe. Avoid many SSH sessions attached to one pane typing at once.

Share one session between users?

Same Unix user can attach together (e.g. shared deploy account). Different users need matching permissions on the socket; most teams use separate sessions plus pairing tools.

Shut tmux down completely?

Exit all panes, or tmux kill-session -t name. tmux kill-server stops every session on that host.

Start a meeting