Skip to content
ohsudo, Home
Linux

tmux Cheat Sheet

tmux commands and shortcuts for keeping work alive on servers: sessions, windows, panes, copy mode, scrolling, sharing a session, and a small tmux.conf

Updated November 6, 2026 · Applies to tmux 3.x · Ubuntu · Debian · RHEL / Rocky / AlmaLinux · macOS

tmux keeps your programs running on the server after your SSH connection drops. Every shortcut below starts with the prefix, Ctrl-b: press that, let go, then press the next key.

Sessions

Terminal window
tmux # start a new session
tmux new -s deploy # start one with a name
tmux ls # list sessions
tmux attach # go back to the latest one
tmux attach -t deploy # go back to this one
tmux kill-session -t deploy # end one
tmux kill-server # end all of them
Ctrl-b d detach (everything keeps running)
Ctrl-b s choose a session from a list
Ctrl-b $ rename this session

Windows

Windows are like tabs.

Ctrl-b c new window
Ctrl-b n next window
Ctrl-b p previous window
Ctrl-b 0..9 go to window number
Ctrl-b w choose from a list
Ctrl-b , rename this window
Ctrl-b & close this window (asks first)

Panes

Panes split a window.

Ctrl-b % split left and right
Ctrl-b " split top and bottom
Ctrl-b arrow move to the next pane
Ctrl-b o next pane
Ctrl-b z zoom this pane (press again to go back)
Ctrl-b x close this pane (asks first)
Ctrl-b ! turn this pane into a window
Ctrl-b Space change the layout
Ctrl-b q show pane numbers
Ctrl-b { swap with the previous pane
Ctrl-b } swap with the next pane

To resize, hold Ctrl and the prefix’s b, then press an arrow key, or use :resize-pane -D 5 for down by 5.

Scroll and copy

Your mouse wheel may not work until you turn it on (below), so use copy mode:

Ctrl-b [ enter copy mode, then arrows or PgUp to scroll
q leave copy mode
Space start selecting
Enter copy the selection
Ctrl-b ] paste

In copy mode, press / to search forward and ? to search backward. If you use Vim keys, set them in the config (below).

Commands

Ctrl-b : type a tmux command
Ctrl-b ? list every shortcut
Ctrl-b t show a clock
Terminal window
tmux send-keys -t deploy 'uptime' Enter # type into a session from outside
tmux new -d -s job './backup.sh' # run something in the background
tmux capture-pane -pt deploy | tail -n 20 # read what's on its screen

Run the same thing on every pane

Ctrl-b :setw synchronize-panes on
Ctrl-b :setw synchronize-panes off

That’s useful with one pane per server. Be careful, as everything you type goes to all of them.

Share a session

Two people logged in as the same user can both attach, and see the same screen:

Terminal window
tmux new -s pair # first person
tmux attach -t pair # second person

A small config

Put this in ~/.tmux.conf:

set -g mouse on # scroll and click with the mouse
set -g history-limit 50000 # keep more scrollback
set -g base-index 1 # number windows from 1
setw -g pane-base-index 1 # and panes
setw -g mode-keys vi # Vim keys in copy mode
set -g escape-time 10 # no lag after Esc in Vim
bind r source-file ~/.tmux.conf \; display "Reloaded"

To load it into a running session: tmux source-file ~/.tmux.conf.

Prefer Ctrl-a as the prefix, as in GNU screen? Add these lines:

unbind C-b
set -g prefix C-a
bind C-a send-prefix

When things look wrong

Other things you may need