tmux cheat sheet: commands and keys

tmux keys start with a prefix, by default Ctrl+b. Press it, let go, then press the key. The essentials are Ctrl+b d to detach, Ctrl+b c for a new window, Ctrl+b % and Ctrl+b " to split, and Ctrl+b [ to scroll. Start or return to a session with tmux new -A -s work.

Updated . tmux 3.5a on Debian 13 in a throwaway container with default settings.

Sessions

TaskCommand or key
Attach to work, or create ittmux new -A -s work
New session in the backgroundtmux new -d -s work
List sessionstmux ls
Attachtmux attach -t work
Detach and leave it runningCtrl+b d
Rename the sessionCtrl+b $
Choose a session from a listCtrl+b s
End a sessiontmux kill-session -t work
End all sessionstmux kill-server
Check whether a session exists, for scriptstmux has-session -t work

Windows

TaskKey
New windowCtrl+b c
Next, previousCtrl+b n, Ctrl+b p
Go to window 0Ctrl+b 0
Last window usedCtrl+b l
RenameCtrl+b ,
Choose from a tree of all windowsCtrl+b w, and q to leave
Close, after confirming with yCtrl+b &

Panes

TaskKey or command
Split side by sideCtrl+b %
Split top and bottomCtrl+b "
Move between panesCtrl+b and an arrow key
Next paneCtrl+b o
Zoom in and outCtrl+b z
Show pane numbersCtrl+b q
Turn a pane into its own windowCtrl+b !
Close, after confirming with yCtrl+b x
Resize by 5 cells to the lefttmux resize-pane -L 5
Swap with the next panetmux swap-pane -D
Equal columnstmux select-layout even-horizontal

Scrolling and copying

TaskKey or command
Enter copy mode to scrollCtrl+b [
Leave copy modeq
Save the last 3000 lines to a filetmux capture-pane -p -S -3000 > out.txt

Other useful keys

TaskKey
List all key bindingsCtrl+b ?
Type a tmux commandCtrl+b :
Show a clockCtrl+b t

Scripting from outside

Every key has a command behind it, so you can drive tmux from a script or over SSH:

tmux new -d -s work
tmux new-window -t work -n logs
tmux split-window -h -t work
tmux send-keys -t work 'echo hello' Enter
tmux capture-pane -p -t work
tmux kill-window -t work:logs

From your own machine, ssh -t user@server tmux new -A -s work goes straight into a session. The -t is needed because tmux wants a terminal.

Configuration

Settings go in ~/.tmux.conf. These two are common:

set -g mouse on
set -g history-limit 50000

Load the file without restarting:

tmux source-file ~/.tmux.conf

Options set while tmux runs last until the tmux server ends. history-limit applies to new panes, not to existing ones.

Messages you may see

MessageMeaning
no server running on /tmp/tmux-1000/defaultNo sessions exist, for example after a reboot
can't find session: workThat name does not exist. Check tmux ls

To learn why sessions survive a dropped connection and what they do not survive, read how to keep SSH sessions alive with tmux.

If you are still choosing between the two tools, see tmux vs screen.

Questions

How do I scroll up in tmux?

Press Ctrl+b [ to enter copy mode, then use the arrow keys or Page Up. Press q to leave. With set -g mouse on in ~/.tmux.conf, the mouse wheel scrolls too.

How do I detach from tmux without ending the session?

Press Ctrl+b d. The session and its programs keep running, and tmux attach -t work brings it back.

How do I close a tmux session?

Run tmux kill-session -t work, or type exit in its last shell. tmux kill-server ends every session.

How do I change the tmux prefix to Ctrl+a?

Add set -g prefix C-a, unbind C-b and bind C-a send-prefix to ~/.tmux.conf, then run tmux source-file ~/.tmux.conf. Press Ctrl+a twice when a program needs Ctrl+a itself.

Sources

More in Sessions and tmux

All guides