Skip to content

SOP-002: Session Management

Fresh
FieldValue
Document IDSOP-002
Version1.1
StatusActive
tmux Version3.6b
Last Updated2026-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-session

Named Session

bash
# Create session named "dev"
tmux new -s dev

# Create session with specific window name
tmux new -s dev -n editor

Attach or Create

bash
# Attach to "work" session, or create it if it doesn't exist
tmux new-session -A -s work

Listing Sessions

bash
# List all sessions
tmux ls
tmux list-sessions

# From within tmux
Ctrl+b s     # Interactive session list

Attaching 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 dev

Detaching from Sessions

MethodAction
Ctrl+b dDetach current client
:attach -dDetach other clients (maximize window)

TIP

Detaching keeps your session running! You can reconnect anytime with tmux attach.

Session Navigation

ShortcutAction
Ctrl+b sShow 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 name

Killing 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 dev

Session 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

See Also

Generated with AI-powered SOP Generator