Skip to main content

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

sudo apt update
sudo apt install -y 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

CheckCommandExpected
tmux installedtmux -VVersion number printed
Session createdtmux new -s testStatus bar appears
Detach worksCtrl+b dReturns to host prompt
Session visibletmux lsSession listed
Reattach workstmux attach -t testSession restored

Common Pitfalls

PitfallSymptomFix
Closing the terminal windowSession killedUse Ctrl+b d to detach first
Old tmux versionFeatures missingInstall from package manager with apt upgrade
Wrong session nameAttach failsUse tmux ls to see actual names

What's Next