Installation and First Run
This lesson walks through installing tmux and completing your first session: create, work, detach, reattach, close.
Learning Focus
Leave this lesson with tmux installed, a working first session, and a clear mental habit for start → detach → reattach → kill.
Install Tmux
- Debian/Ubuntu
- RHEL/Fedora/AlmaLinux
- Arch Linux
- macOS (Homebrew)
sudo apt update
sudo apt install -y tmux
tmux -V
sudo dnf install -y tmux
tmux -V
sudo pacman -S tmux
tmux -V
brew install tmux
tmux -V
info
Most modern Linux servers have tmux in their default repositories. Version 3.0+ is recommended for all features in this track.
Verify Installation
tmux -V
Expected output:
tmux 3.3a
Your First Session (Full Workflow)
Step 1: Start a Named Session
tmux new-session -s mywork
# or shorter:
tmux new -s mywork
Your terminal is now inside the tmux session. You will see a status bar at the bottom.
Step 2: Run Something
# Run a long-running command
ping google.com
Step 3: Detach (Keep It Running)
Press: Ctrl+b, release, then d
You are now back at the host shell. The ping is still running inside tmux.
Step 4: Verify Session is Alive
tmux ls
Output:
mywork: 1 windows (created Mon Apr 7 04:06:00 2026)
Step 5: Reattach
tmux attach -t mywork
# or shorter:
tmux a -t mywork
You are back — the ping is still running, nothing was lost.
Step 6: Close Cleanly
# Stop the ping (Ctrl+C), then exit the shell
exit
The session closes once all its windows exit.
Session Lifecycle Summary
stateDiagram-v2
[*] --> Created: tmux new -s name
Created --> Active: shell / processes running
Active --> Detached: Ctrl+b d
Detached --> Active: tmux attach -t name
Active --> Closed: all windows exit / kill-session
Detached --> Closed: tmux kill-session -t name
Closed --> [*]
What the Status Bar Tells You
When inside a session, the bottom bar shows:
[mywork] 0:bash* "server01" 04:06 07-Apr-26
│ │ │
Session Window name + *=active Hostname and time
Common Setup Check
| Check | Command | Expected |
|---|---|---|
| tmux installed | tmux -V | Version number printed |
| Session created | tmux new -s test | Status bar appears |
| Detach works | Ctrl+b d | Returns to host prompt |
| Session visible | tmux ls | Session listed |
| Reattach works | tmux attach -t test | Session restored |
Common Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Closing the terminal window | Session killed | Use Ctrl+b d to detach first |
| Old tmux version | Features missing | Install from package manager with apt upgrade |
| Wrong session name | Attach fails | Use tmux ls to see actual names |