Run without installing
Basics: bash <(curl -sL https://raw.githubusercontent.com/alejandroerickson/tmuxtutor/main/tmuxtutor)
Advanced: bash <(curl -sL https://raw.githubusercontent.com/alejandroerickson/tmuxtutor/main/tmuxtutor-advanced)

Basics

Lesson 1 — Create a Session

tmux organises everything into sessions. A session is the outermost container — it holds windows, panes, and processes. Named sessions are easier to find and reattach to later.

Commands
$ tmux new -s learn
Tip: The -s flag names the session. A green status bar at the bottom means you are inside tmux.
Verify: The tutor checks that a session named "learn" exists.

Lesson 2 — Detach

tmux's killer feature: you can detach from a session and it keeps running in the background. Close your laptop, SSH back tomorrow — the session is still there.

Keybinding
Ctrl+bthend detach from the current session
Tip: You will be dropped back to a regular shell prompt. The session is still running — just not attached to any terminal.
Verify: Checks that session "learn" exists and is detached (attached=0).

Lesson 3 — Reattach

Your "learn" session is still running in the background. Reattach to pick up where you left off.

Commands
$ tmux attach -t learn
Shorthand: tmux a attaches to the most recent session. List all sessions with tmux ls.
Verify: Checks that session "learn" is attached (attached != 0).

Lesson 4 — Create Windows

Inside a session you can have multiple windows — think of them as tabs. Each is a full-screen terminal.

Keybindings
Ctrl+bthenc create a new window
Ctrl+bthenn next window
Ctrl+bthenp previous window
Ctrl+bthen0 jump to window 0
Tip: Look at the status bar — the * marks the active window.
Verify: Checks that the "learn" session has at least 2 windows.

Lesson 5 — Name Your Windows

Window names like "0:zsh" don't tell you much. Give them meaningful names so the status bar is useful at a glance.

Keybindings
Ctrl+bthen0 go to window 0
Ctrl+bthen, rename the current window (type main, press Enter)
Ctrl+bthen1 go to window 1
Ctrl+bthen, rename it (type work, press Enter)
Verify: Checks for windows named "main" and "work" in the "learn" session.

Lesson 6 — Split into Panes

A window can be divided into panes — multiple terminals visible at once. Navigate to the "work" window and split it.

Keybindings
Ctrl+bthen% split left / right (vertical divider)
Ctrl+bthen" split top / bottom (horizontal divider)
Ctrl+bthenarrow keys move between panes
Ctrl+btheno cycle to next pane
Tip: Use Ctrl+b then w to open the interactive window list.
Verify: Checks that the "work" window has at least 2 panes.

Lesson 7 — Split the Other Way

Add a second split in a different direction to build a multi-pane layout. If you split vertically last time, try horizontal now (or vice versa).

Keybindings
Ctrl+bthen% vertical split (if you split horizontally before)
Ctrl+bthen" horizontal split (if you split vertically before)
Tip: A typical layout is an editor on the left, tests top-right, logs bottom-right. You should end up with 3 panes.
Verify: Checks for at least 3 panes in the "work" window.

Lesson 8 — Zoom a Pane

When you need to focus on one pane, zoom it to fill the entire window. The other panes stay alive — just hidden.

Keybinding
Ctrl+bthenz toggle zoom on the current pane
Tip: The status bar shows a Z flag when a pane is zoomed. Press the same combo again to unzoom.
Verify: Checks that the "work" window has a zoomed pane (zoomed_flag=1).

Lesson 9 — Kill a Pane

Remove a pane you no longer need. First unzoom if the window is still zoomed, then kill one of the three panes.

Keybindings
Ctrl+bthenz toggle zoom off
Ctrl+bthenx kill current pane (press y to confirm)
Verify: Checks for exactly 2 panes in "work" and no zoom.

Lesson 10 — Create a Window

Practice the full window lifecycle. Create a temporary window and name it "scratch".

Keybindings
Ctrl+bthenc create a new window
Ctrl+bthen, rename it to scratch
Verify: Checks for 3 windows in "learn" including one named "scratch".

Lesson 11 — Kill a Window

Now remove the "scratch" window you just created.

Keybindings
Ctrl+bthenw interactive window list — select scratch
Ctrl+bthen& kill current window (press y to confirm)
Verify: Checks for exactly 2 windows (main + work) with no "scratch".

Lesson 12 — Runtime Configuration

tmux settings can be changed at runtime through the command prompt. Open it, type a command, and press Enter.

Keybinding
Ctrl+bthen: open the tmux command prompt
Commands (type these at the prompt)
  • : set -g mouse on
  • : set -g mode-keys vi
Tip: The command prompt supports Tab completion. mouse on enables click-to-select panes, scroll with wheel, and drag-to-resize. mode-keys vi enables vim keybindings in copy mode. To make these permanent, add them to ~/.tmux.conf.
Verify: Checks that mouse=on and mode-keys=vi in the running server.

Lesson 13 — Copy Mode

Copy mode lets you scroll, search, and copy text without a mouse. You will copy a marker string into the tmux paste buffer.

Step 1 — Print the marker
$ echo TMUXTUTOR_COPY_TEST
Step 2 — Enter copy mode
Ctrl+bthen[
Step 3 — Find, select, copy (vi keys)
/ search — type TMUXTUTOR_COPY_TEST, press Enter
Space start selection
e extend to end of word
Enter copy and exit copy mode
Verify: Checks that the tmux paste buffer contains "TMUXTUTOR_COPY_TEST".

Lesson 14 — Build a Workspace

Capstone: put it all together. Build a workspace from scratch with a new session, named windows, and pane splits.

Steps
Ctrl+bthend detach from "learn"
$ tmux new -s project
Ctrl+bthen, rename the first window to editor
Ctrl+bthen% split it vertically
Ctrl+bthenc create a second window
Ctrl+bthen, rename it to shell
Result: Session "project" with "editor" (2 panes) + "shell".
Verify: Checks for session "project" with windows "editor" (2+ panes) and "shell".

Advanced

Lesson 1 — Kill a Session

Sessions accumulate. Sometimes you need to kill one. Create two throwaway sessions, then kill only the first.

Commands
  • $ tmux new -d -s temp1
  • $ tmux new -d -s temp2
  • $ tmux ls
  • $ tmux kill-session -t temp1
Tip: The -d flag creates sessions in the background (detached). The nuclear option tmux kill-server destroys every session — use with caution.
Verify: Checks that temp1 is gone and temp2 is still alive.

Lesson 2 — Switch Between Sessions

When you have multiple sessions, you can switch between them without detaching and reattaching.

Keybindings
Ctrl+bthens interactive session list
Ctrl+bthen) next session
Ctrl+bthen( previous session
Or via command prompt
Ctrl+bthen: then type switch-client -t temp2
Verify: Checks for at least 2 sessions with at least 1 attached.

Lesson 3 — Resize Panes

Control pane geometry. Create session "adv" with a "resize" window, split it, then make the right pane wider.

Setup commands
  • $ tmux new -d -s adv -n resize
  • $ tmux split-window -h -t '=adv:=resize'
  • $ tmux attach -t adv
Resize methods
Ctrl+bthenCtrl+Right grow right by 1 cell (repeat)
Ctrl+bthen: then type resize-pane -R 20
Tip: The command prompt supports Tab completion — type resi then press Tab. Goal: the right pane should be wider than 55% of the window.
Verify: Checks that pane 1 occupies at least 55% of the window width.

Lesson 4 — Swap Panes

Swap the positions of two panes without moving yourself or retyping anything. Put identifying text in each pane, then swap them.

Target a pane by number
Ctrl+bthenqthen0 flash pane numbers, then select pane 0
Swap keybindings
Ctrl+bthen{ swap current pane with the previous one
Ctrl+bthen} swap current pane with the next one
Verify: Captures pane contents and checks that pane 0 shows PANE_B and pane 1 shows PANE_A (swapped).

Lesson 5 — Pane Layouts

tmux has built-in layout presets that rearrange all panes at once. Add a third pane to "resize", then cycle through layouts.

Keybinding
Ctrl+bthenSpace cycle through layout presets
Or set a specific layout
Ctrl+bthen: then type select-layout tiled
Available layouts: even-horizontal (equal columns), even-vertical (equal rows), main-horizontal (big top, rest below), main-vertical (big left, rest right), tiled (grid).
Verify: Checks for at least 3 panes in the "resize" window.

Lesson 6 — Move Panes Between Windows

Panes can be broken out of a window or joined into another. Create a "staging" window, break a pane from "resize", and join it into "staging".

Keybindings
Ctrl+bthen! break current pane into its own window
Join via command prompt
Ctrl+bthen: then type join-pane -t :staging
Verify: Checks that "staging" window has at least 2 panes.

Lesson 7 — Paste and Buffers

tmux maintains its own paste buffers independent of the system clipboard. Copy text in copy mode and paste it back. Multiple copies stack up.

Copy flow (vi keys)
$ echo ADVANCED_PASTE_TEST
Ctrl+bthen[ enter copy mode
/ search, then Space to select, Enter to copy
Paste and buffer management
Ctrl+bthen] paste the most recent buffer
Ctrl+bthen= choose from buffer list
$ tmux list-buffers
Verify: Checks that the paste buffer contains "ADVANCED_PASTE_TEST".

Lesson 8 — Help and Introspection

tmux has a built-in help system. Browse every keybinding, query options, and inspect the running server.

Keybinding
Ctrl+bthen? list all keybindings (q to exit)
Shell commands
  • $ tmux list-keys
  • $ tmux show-options -g
  • $ tmux info
Discovered binding
Ctrl+bthenl switch to the last-used window
Verify: Checks that session "adv" has at least 2 windows.

Lesson 9 — Edit tmux.conf

Runtime settings vanish when the server exits. Put them in ~/.tmux.conf to make them permanent.

Recommended config lines
  • set -g mouse on
  • set -g mode-keys vi
  • set -g history-limit 50000
  • set -g base-index 1
  • set -g status-style 'bg=colour235 fg=colour75'
Reload the config
$ tmux source-file ~/.tmux.conf
Tip: You can also reload from the tmux command prompt: Ctrl+b then : then type source-file ~/.tmux.conf. Back up any existing config first with cp ~/.tmux.conf ~/.tmux.conf.bak.
Verify: Checks that ~/.tmux.conf contains mouse on, mode-keys vi, and history-limit, and that they are active in the running server.

Lesson 10 — Custom Key Bindings

The default split keys % and " are hard to remember. Bind more intuitive keys that look like the dividers they create.

Add to ~/.tmux.conf
  • bind | split-window -h -c "#{pane_current_path}"
  • bind - split-window -v -c "#{pane_current_path}"
After reloading config
Ctrl+bthen| split side by side (vertical divider)
Ctrl+bthen- split stacked (horizontal divider)
Tip: The -c "#{pane_current_path}" flag opens the new pane in the same directory as the current pane.
Verify: Checks that both bindings exist in ~/.tmux.conf and are loaded into the running server.

Lesson 11 — Synchronized Panes

Type the same command into multiple panes at once — useful for updating several servers simultaneously.

Turn sync on
Ctrl+bthen: then type setw synchronize-panes on
Turn sync off
Ctrl+bthen: then type setw synchronize-panes off
Verify: Checks that synchronize-panes is "on" and the current window has 2+ panes.

Lesson 12 — Script a Workspace

tmux's real power is scripting. Every command you have used interactively can be run from a shell script to build a workspace automatically.

Key concepts
-d create detached — -t session:window target a window — -t session:window.pane target a pane — send-keys ... Enter type a command into a pane.
Scripted commands
  • $ tmux new-session -d -s dev -n editor
  • $ tmux split-window -h -t dev:editor
  • $ tmux new-window -t dev -n logs
  • $ tmux send-keys -t dev:editor.0 'echo EDITOR_READY' Enter
  • $ tmux send-keys -t dev:logs 'echo LOGS_READY' Enter
  • $ tmux attach -t dev
Verify: Checks for session "dev" with "editor" (2+ panes, EDITOR_READY marker) and "logs" (LOGS_READY marker).

Lesson 13 — SSH and tmux

tmux really shines over SSH. Set up a real SSH server, connect from another device, and attach to a tmux session remotely. If the connection drops, the session keeps running — just reconnect and reattach.

Step 1 — Install and start the SSH server

Ubuntu / Debian:

  • $ sudo apt install openssh-server
  • $ sudo systemctl enable ssh && sudo systemctl start ssh

Fedora:

  • $ sudo dnf install openssh-server
  • $ sudo systemctl enable sshd && sudo systemctl start sshd

Arch:

  • $ sudo pacman -S openssh
  • $ sudo systemctl enable sshd && sudo systemctl start sshd

macOS:

Enable via System Settings → General → Sharing → Remote Login, or:

  • $ sudo systemsetup -setremotelogin on
Step 2 — Create a tmux session to connect to
  • $ tmux new -d -s remote
  • $ tmux send-keys -t remote 'echo SSH_WORKFLOW_TEST' Enter
Step 3 — Find your IP address
$ hostname -I
Step 4 — SSH in from another device and attach
  • $ ssh user@<your-ip>
  • $ tmux attach -t remote
Attach-or-create: tmux new -A -s <name> attaches if the session exists, or creates it if not. The "always works" command.
WAN access: To connect from outside your local network, set up port forwarding on your router (port 22) or use Tailscale for a zero-config VPN.
Security: Set up SSH key authentication and disable password login for production servers. See ssh-keygen and ~/.ssh/authorized_keys.
Verify: Checks that sshd is running, session "remote" exists, marker text "SSH_WORKFLOW_TEST" is present, and the session is attached.

Lesson 14 — Build a Dev Environment

Capstone: build a multi-session dev environment from scratch using scripted commands. Two sessions, each with multiple windows and panes.

Backend session
  • $ tmux new-session -d -s backend -n api
  • $ tmux split-window -h -t backend:api
  • $ tmux new-window -t backend -n db
Frontend session
  • $ tmux new-session -d -s frontend -n app
  • $ tmux split-window -h -t frontend:app
  • $ tmux new-window -t frontend -n tests
Send markers and attach
  • $ tmux send-keys -t backend:api.0 'echo BACKEND_API' Enter
  • $ tmux send-keys -t frontend:app.0 'echo FRONTEND_APP' Enter
  • $ tmux attach -t backend
Ctrl+bthens switch between backend and frontend
Result: Two sessions (backend + frontend), each with named windows and split panes. Imagine scripting this into a single dev-start.sh you run every morning.
Verify: Checks both sessions exist with correct windows, pane counts, and marker text.

Quick Reference

All keybindings and commands taught across both modules.

Sessions

tmux new -s <name>Create a named session
tmux new -d -s <name>Create detached (background)
tmux new -A -s <name>Attach or create
Ctrl+bthendDetach from session
tmux attach -t <name>Reattach to session
tmux aAttach to most recent session
tmux lsList all sessions
tmux kill-session -t <name>Kill a session
Ctrl+bthensInteractive session list
Ctrl+bthen)Next session
Ctrl+bthen(Previous session
switch-client -t <name>Switch to named session (at prompt)

Windows

Ctrl+bthencCreate a new window
Ctrl+bthen,Rename current window
Ctrl+bthennNext window
Ctrl+bthenpPrevious window
Ctrl+bthen09Jump to window by number
Ctrl+bthenwInteractive window list
Ctrl+bthenlLast-used window
Ctrl+bthen&Kill current window (confirm y)

Panes

Ctrl+bthen%Split left / right
Ctrl+bthen"Split top / bottom
Ctrl+bthen|Split left / right (custom binding)
Ctrl+bthen-Split top / bottom (custom binding)
Ctrl+bthenarrow keysMove between panes
Ctrl+bthenoCycle to next pane
Ctrl+bthenqShow pane numbers
Ctrl+bthenzToggle zoom
Ctrl+bthenxKill pane (confirm y)
Ctrl+bthen{Swap with previous pane
Ctrl+bthen}Swap with next pane
Ctrl+bthen!Break pane into own window
Ctrl+bthenSpaceCycle layout presets
Ctrl+bthenCtrl+arrowResize pane
resize-pane -R <n>Resize by n cells (at prompt)
join-pane -t :<window>Join pane into another window (at prompt)
select-layout <name>Set layout preset (at prompt)
setw synchronize-panes on|offSync input across panes (at prompt)

Copy Mode

Ctrl+bthen[Enter copy mode
/ then textSearch (in copy mode)
SpaceStart selection (in copy mode)
eExtend to end of word (in copy mode)
EnterCopy selection and exit
Ctrl+bthen]Paste most recent buffer
Ctrl+bthen=Choose from buffer list
tmux list-buffersList all paste buffers

Config

Ctrl+bthen:Open command prompt
Ctrl+bthen?List all keybindings
set -g mouse onEnable mouse support
set -g mode-keys viVi keybindings in copy mode
set -g history-limit 50000Increase scrollback buffer
set -g base-index 1Start window numbering at 1
tmux source-file ~/.tmux.confReload config file
bind <key> <command>Create a custom key binding
tmux list-keysList all key bindings (shell)
tmux show-options -gShow all global options
tmux infoServer and terminal info

Scripting

tmux new-session -d -s <s> -n <w>Create session + named window (detached)
tmux new-window -t <s> -n <w>Add a window to a session
tmux split-window -h -t <s>:<w>Split a window horizontally
tmux split-window -v -t <s>:<w>Split a window vertically
tmux send-keys -t <s>:<w>.<p> '...' EnterSend a command to a pane