Utiliser tmux : installation, sessions, fenêtres, volets, détacher et rattacher
Installez tmux, gérez sessions, fenêtres et volets, détachez sans tuer les processus, rattachez-vous quand vous voulez.
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.
À quoi sert tmux
Sessions survive disconnects
Press Ctrl+b then d to detach. Builds, log tails, and migrations keep running when SSH drops.
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.
Named, scriptable sessions
tmux new -s deploy names a session; tmux ls lists; tmux attach -t deploy returns. Common on shared jump hosts.
Installation macOS et Linux
-
1
macOS: Homebrew
Run
brew install tmuxand confirm withtmux -V. Apple Silicon and Intel use the same formula. -
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
Fedora / Arch
Fedora:
sudo dnf install tmux. Arch:sudo pacman -S tmux. Typingtmuxstarts a new session with a status bar. -
4
First run and exit
Plain
tmuxcreates a numbered session. To end it,exitevery pane or runtmux kill-session. To leave temporarily, detach — do not just close SSH.
Sessions : créer, lister, rattacher
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.
Fenêtres et volets : préfixe Ctrl+b
Press the prefix (default Ctrl+b), then the command key.
| After prefix | Action | Use case |
|---|---|---|
c | New window | Fresh shell line |
n / p | Next / previous window | Switch tabs |
0–9 | Jump to window | Status bar index |
% | Split left/right | Logs + shell |
" | Split top/bottom | Monitor + edit |
| Arrow keys | Move between panes | Multi-pane work |
x | Close pane | Confirm y/n |
d | Detach session | Before SSH drops |
? | Shortcut list | When you forget keys |
Config de base ~/.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 vior plugins like vim-tmux-navigator per their docs.
For whiteboard or voice sync, open a browser room from the wbroom homepage — créer et rejoindre une salle.
À vérifier
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.