Tmux Commands: Essential Commands & Shortcuts (With Examples)

l9c l9c

TL;DR — Start with tmux new -s mysession, list with tmux ls, run any action as tmux <command>, and use the prefix for shortcuts: Ctrl+b ? lists the noted bindings, Ctrl+b d detaches.

How tmux commands are structured

tmux has three entry points, and mixing them up is the main source of confusion:

  • Shell commands — typed at your normal prompt as tmux <command>. They talk to the tmux server and mostly work whether or not you are attached; attach, and new when it would attach, are refused from a shell inside tmux (unset $TMUX to force), and commands that act on a client need one (or an explicit client target).
  • Key bindings — the prefix (Ctrl+b by default) followed by one key. Each binding simply runs a command: Ctrl+b % runs split-window -h.
  • Command mode — Ctrl+b : opens a prompt inside tmux where you type the command name directly, for example rename-session mysession.

The 30 essential tmux commands

Grouped by what you are trying to do. Every command also accepts the prefix plus : form when you are already inside tmux.

Sessions

CommandLong nameWhat it does
tmux new -s mysession
new-sessionCreates a named session and attaches this terminal to it.
tmux ls
list-sessionsShows each session with its window count and whether a client is attached.
tmux attach -t mysession
attach-sessionReconnects this terminal to the named session.
tmux detach
detach-clientDisconnects the client while the session and its processes keep running.
tmux kill-session -t mysession
kill-sessionEnds the named session and the windows that exist only in it; windows also linked to another session keep running.
tmux kill-server
kill-serverShuts down the tmux server, which ends all sessions.
tmux rename-session mysession
rename-sessionChanges the current session's name.

Windows

CommandLong nameWhat it does
tmux new-window -n logs
new-windowAdds a window and gives it a label in the status bar.
tmux list-windows
list-windowsLists windows in the current session and marks the active one.
tmux select-window -t mysession:2
select-windowMoves focus to a window by index or name.
tmux rename-window logs
rename-windowRenames the window you are in.
tmux kill-window -t mysession:1
kill-windowCloses a window together with its panes.
tmux move-window -t mysession:5
move-windowMoves a window to another index in a session.

Panes

CommandLong nameWhat it does
tmux split-window -h
split-windowSplits the current window side by side; use -v for top and bottom.
tmux select-pane -L
select-paneFocuses the pane to the left; -R, -U and -D cover the other directions.
tmux resize-pane -R 10
resize-paneResizes the current pane ten columns to the right.
tmux kill-pane
kill-paneCloses the current pane and lets the remaining panes reflow.
tmux swap-pane -U
swap-paneSwaps the current pane with the previous pane by number.
tmux break-pane
break-paneTurns the current pane into a separate window.
tmux join-pane -s mysession:0.1
join-paneBrings an existing pane into the current window.

Copy mode and buffers

CommandLong nameWhat it does
tmux copy-mode -u
copy-modeEnters scrollback one page up so you can navigate history.
tmux save-buffer ~/tmux-buffer.txt
save-bufferWrites the latest copy buffer to a file.
tmux paste-buffer
paste-bufferPastes the latest buffer into the active pane.
tmux capture-pane -p -t mysession:0.1
capture-panePrints a pane's visible contents to stdout.

Scripting and options

CommandLong nameWhat it does
tmux send-keys -t mysession:0.1 'npm test' Enter
send-keysTypes text and key names into another pane.
tmux list-panes
list-panesLists panes with ids and geometry for scripts.
tmux list-keys
list-keysPrints every key binding and its command.
tmux source-file ~/.tmux.conf
source-fileReloads a config file in the running server.
tmux set -g mouse on
set-optionSets the global session option, which sessions without their own value inherit; use off to disable mouse.
tmux show-options -g
show-optionsPrints the global session options; use -s for server options and -w for window options.

Essential tmux key bindings

ShortcutAction
Ctrl+b cCreate a window
Ctrl+b n / pNext / previous window
Ctrl+b 0–9Jump to a window by index
Ctrl+b wPick a window from a list
Ctrl+b ,Rename the current window
Ctrl+b &Kill the current window
Ctrl+b %Split side by side
Ctrl+b "Split top and bottom
Ctrl+b + arrowMove between panes
Ctrl+b oCycle through panes
Ctrl+b zZoom / unzoom the active pane
Ctrl+b qShow pane numbers
Ctrl+b xClose the active pane
Ctrl+b { / }Swap panes
Ctrl+b SpaceNext layout
Ctrl+b [Enter copy mode
Ctrl+b ]Paste the buffer
Ctrl+b ?List the noted key bindings (tmux list-keys shows all)
Ctrl+b :Open the command prompt
Ctrl+b dDetach from the session
Ctrl+b $Rename the current session

See the top 10 commands in action

The recording starts at a shell prompt and runs ten of the commands above end to end: create a session, split, select panes, resize, open a second window, detach, list the session with tmux ls, reattach, and clean up.

Frequently asked questions

What is the tmux prefix key?

The prefix is Ctrl+b by default. Press it, release it, then press the command key: Ctrl+b then c creates a window, Ctrl+b then d detaches. The prefix only applies while you are inside tmux; shell commands are typed as tmux <command>.

How do I see all tmux commands?

Run tmux list-commands from a shell to print every server command with its flags. For the noted key bindings, run tmux lsk -N | more from a shell, or press Ctrl+b then ? inside tmux; run tmux list-keys for every binding together with its command.

How do I run a tmux command without the prefix?

Type it as a shell command, for example tmux list-windows or tmux split-window -h. Inside tmux you can also press Ctrl+b then : to open the command prompt and enter the command name there.

What is the difference between a tmux command and a key binding?

A command is the action itself, such as split-window or detach-client. A key binding is a shortcut that runs a command: by default Ctrl+b % runs split-window -h. You can inspect bindings with tmux list-keys.

Which tmux version do these commands target?

This list is verified against tmux 3.8. Check your own version with tmux -V. Older releases lack a few newer commands and flags, so confirm anything unusual against your version.

How do I run a command in another tmux pane?

Address the pane as session:window.pane and use tmux send-keys -t mysession:0.1 "npm test" Enter. Add key names such as Enter after the text so the line actually runs. Read the result back with tmux capture-pane -p -t mysession:0.1.

How do I reload .tmux.conf without restarting tmux?

Run tmux source-file ~/.tmux.conf. The running server reloads the file and keeps every session, window and pane alive. If a line has a syntax error, tmux reports the file and line number and the previous settings stay in effect.

Keep exploring with the tmux cheat sheet and build a starting config with the tmux config generator.