Tools › Cheat sheets › Linux & Shell › tmux
🪟

tmux cheat sheet

tmux keeps your terminal sessions running when your SSH connection drops. Every shortcut starts with the prefix, Ctrl-b by default: press it, release, then press the key.

Click any command to copy it.

Sessions

CommandWhat it does
tmux new -s nameStart a named session.
tmux lsList sessions.
tmux attach -t nameAttach to a session (or 'tmux a' for the latest).
Ctrl-b dDetach from the session, leaving it running.
Ctrl-b $Rename the session.
tmux kill-session -t nameDestructive: Kill a session and everything running in it.
Ctrl-b sChoose a session from a list.

Windows (tabs)

CommandWhat it does
Ctrl-b cCreate a new window.
Ctrl-b n / Ctrl-b pNext / previous window.
Ctrl-b 0 ... 9Jump to window by number.
Ctrl-b ,Rename the window.
Ctrl-b wChoose a window from a list.
Ctrl-b &Close the window (asks first).

Panes (splits)

CommandWhat it does
Ctrl-b %Split left/right.
Ctrl-b "Split top/bottom.
Ctrl-b arrow keysMove between panes.
Ctrl-b zZoom a pane to full screen and back.
Ctrl-b xClose the pane (asks first).
Ctrl-b { / Ctrl-b }Swap the pane with the previous / next one.
Ctrl-b SpaceCycle through pane layouts.
Ctrl-b Alt-arrowResize the pane.

Scrolling and copying

CommandWhat it does
Ctrl-b [Enter copy mode to scroll with arrows, PageUp and PageDown.
qLeave copy mode.
Ctrl-b ]Paste the tmux buffer.
Ctrl-b ?List all key bindings.

Configuration

CommandWhat it does
set -g mouse onIn ~/.tmux.conf: enable mouse scrolling and pane selection.
set -g history-limit 50000In ~/.tmux.conf: keep more scrollback.
tmux source-file ~/.tmux.confReload the configuration.
Ctrl-b :Open the tmux command prompt.

Frequently asked questions

How do I keep a command running after I disconnect?

Start it inside tmux, detach with Ctrl-b d, then log out. Reattach later with tmux attach.

How do I scroll in tmux?

Press Ctrl-b [ to enter copy mode, then use the arrow keys or PageUp. Or enable set -g mouse on to scroll with the mouse wheel.

More Linux & Shell cheat sheets

🐚 Bash🔎 grep🔍 find✂️ sed🧮 awk📦 tar📝 Vim🔐 chmod permissionsAll Linux & Shell cheat sheets →
Copied to clipboard