learntmux.dev
LEVEL 1 · BASICS

Sessions, the prefix key, panes, windows, detach and reattach.

Start a session, learn the prefix key that every other shortcut hangs off, split the window into panes, and detach without losing your work.

11 tasks · about 46 minutes · 25 key bindings

Start with task 1
  1. 01

    Start your first session

    3 min

    Run tmux from the shell to start the server, create a named session and see the status line.

    tmux newtmux new -s nametmux new -n name
  2. 02

    The prefix key and new windows

    3 min

    Press the prefix key for the first time to open new windows and watch the window list grow in the status line.

    C-bthencC-bthenC-b
  3. 03

    Find any key with the help list

    4 min

    Open the built-in key list in view mode, scroll it, look up a single key, then use a key you found there.

    C-bthen?C-bthen/C-bthent
  4. 04

    Run commands from the command prompt

    3 min

    Use the tmux command prompt to run new-window with flags instead of a key binding.

    C-bthen::neww -d -n name:neww command
  5. 05

    Detach and come back

    4 min

    Start a log tail, detach from the session, and reattach to find it still running.

    C-bthendtmux attach -t name
  6. 06

    Read the session list and juggle sessions

    5 min

    List sessions from the shell, pick the right one by its window count, run a program in a new session, and reattach safely with new -A.

    tmux lstmux new -s name -n name commandtmux new -A -s name
  7. 07

    Split the window into panes

    3 min

    Cut one pane into two side by side, then split the right one top and bottom.

    C-bthen%C-bthen"
  8. 08

    Split with flags

    4 min

    Use split-window flags from the command prompt to make a full-width bottom pane, a full-height left pane, and one that does not steal focus.

    :splitw -fv:splitw -fhb:splitw -d
  9. 09

    Move between panes

    4 min

    Change the active pane with the arrow keys, cycle with o, and jump by number with q.

    C-bthenUpC-bthenoC-bthenq
  10. 10

    Kill the server

    3 min

    Shut down every session at once with kill-server, and see why exiting the last shell does the same.

    :kill-server
  11. 11

    Challenge: morning on the build box

    challenge10 min

    From a bare shell, build session work: an editor window, a build window with a full-width log pane, and a monitor window, then detach and come back.