Back
4/61
Lesson 4
7 min

tmux Basics

Keep your work running when you disconnect

New to ACFS?

Complete the setup wizard first to get the most from these lessons.

Go to Choose Your OS
Goal

Never lose work when SSH drops.

What Is tmux?

tmux is a terminal multiplexer. It lets you:

  • Keep sessions running after you disconnect
  • Split your terminal into panes
  • Have multiple windows in one connection

Try Splitting Panes

Click panes to select them, then use the buttons to split or close. This simulates what Ctrl+a shortcuts do in a real tmux session.

tmux - myproject
ubuntu@vps:~$ npm run dev
VITE v5.4.1 ready in 312 ms
> Local: http://localhost:5173/
> Network: http://192.168.1.42:5173/
watching for file changes...
ubuntu@vps:~$
[myproject]
10:42

Essential Commands

Start a New Session

bash
tmux new -s myproject

This creates a session named "myproject".

Detach (Leave Session Running)

Press:Ctrl+athend

Your session continues running in the background!

List Sessions

bash
tmux ls

See all running sessions.

Reattach to a Session

bash
tmux attach -t myproject
# Or just:
tmux a

Attaches to the most recent session.

The Prefix Key

Note
In ACFS, the prefix key is Ctrl+a (not the default Ctrl+b). All tmux commands start with the prefix.

Splitting Panes

Ctrl+a+|
Split vertically
Ctrl+a+-
Split horizontally
Ctrl+a+h/j/k/l
Move between panes
Ctrl+a+x
Close current pane

Windows (Tabs)

Ctrl+a+c
New window
Ctrl+a+n
Next window
Ctrl+a+p
Previous window
Ctrl+a+0-9
Go to window number

Copy Mode (Scrolling)

Ctrl+a+[
Enter copy mode
j/k+or arrows
Scroll
q
Exit copy mode
v
Start selection
y
Copy selection

Try It Now

bash
1# Create a session
2$ tmux new -s practice
3
4# Split the screen
5# Press Ctrl+a, then |
6
7# Move to the new pane
8# Press Ctrl+a, then l
9
10# Run something
11$ ls -la
12
13# Detach
14# Press Ctrl+a, then d
15
16# Verify it's still running
17$ tmux ls
18
19# Reattach
20$ tmux attach -t practice

Why This Matters for Agents

Your Agents Run in tmux

Your coding agents (Claude, Codex, Gemini) run in tmux panes. If SSH drops, they keep running. When you reconnect and reattach, they're still there!

Ready to level up?

Mark complete to track your learning progress.