SOP-002: Session Management
Fresh| Field | Value |
|---|---|
| Document ID | SOP-002 |
| Version | 1.1 |
| Status | Active |
| tmux Version | 3.6b |
| Last Updated | 2026-05-26 |
Purpose
Create, manage, attach to, and detach from tmux sessions effectively.
Prerequisites
- tmux installed (SOP-001)
- Terminal access
Session Lifecycle
Procedure
Creating Sessions
Basic Session
bash
# Start a new session (auto-named)
tmux
# Or explicitly
tmux new
tmux new-sessionNamed Session
bash
# Create session named "dev"
tmux new -s dev
# Create session with specific window name
tmux new -s dev -n editorAttach or Create
bash
# Attach to "work" session, or create it if it doesn't exist
tmux new-session -A -s workListing Sessions
bash
# List all sessions
tmux ls
tmux list-sessions
# From within tmux
Ctrl+b s # Interactive session listAttaching to Sessions
bash
# Attach to last session
tmux a
tmux at
tmux attach
tmux attach-session
# Attach to named session
tmux a -t dev
tmux attach -t devDetaching from Sessions
| Method | Action |
|---|---|
Ctrl+b d | Detach current client |
:attach -d | Detach other clients (maximize window) |
TIP
Detaching keeps your session running! You can reconnect anytime with tmux attach.
Session Navigation
| Shortcut | Action |
|---|---|
Ctrl+b s | Show session list |
Ctrl+b ( | Previous session |
Ctrl+b ) | Next session |
Ctrl+b $ | Rename current session |
Renaming Sessions
bash
# From command line
tmux rename-session -t old-name new-name
# From within tmux
Ctrl+b $ # Then type new nameKilling Sessions
bash
# Kill specific session
tmux kill-session -t dev
tmux kill-ses -t dev
# Kill current session (from within tmux)
:kill-session
# Kill all sessions except current
tmux kill-session -a
# Kill all sessions except "dev"
tmux kill-session -a -t devSession Workflow Example
Verification
Check session status:
bash
# List sessions with details
tmux ls
# Example output:
# dev: 3 windows (created Mon Jan 29 10:00:00 2025)
# work: 1 windows (created Mon Jan 29 09:00:00 2025) (attached)Troubleshooting
"no sessions" when trying to attach
Solution
No sessions exist. Create one first:
bash
tmux new -s mysession"sessions should be nested with care"
Solution
You're already in tmux trying to start another tmux. Instead:
- Create a new window:
Ctrl+b c - Switch sessions:
Ctrl+b s - Or detach first:
Ctrl+b d
Session lost after SSH disconnect
Solution
The session is still running! Simply reconnect and reattach:
bash
ssh user@server
tmux attach