Skip to content
shellhacks.dev

tmux Cheat Sheet

A searchable tmux cheat sheet: creating, detaching and reattaching sessions, windows, splitting and moving between panes, scroll mode, synchronised panes and useful config lines.

Free · No sign-up · Your inputs stay in your browser

Reference

tmux cheat sheet

Keys or commandDoes
tmux new -s deployNew named session
tmux lsList sessions
tmux attach -t deployReattach to a session (a for short)
tmux kill-session -t deployEnd a session
Ctrl-b dDetach: the session keeps running after you disconnect
Ctrl-b cNew window
Ctrl-b n / pNext / previous window
Ctrl-b 0-9Go to window by number
Ctrl-b ,Rename window
Ctrl-b wPick a window from a list
Ctrl-b %Split side by side
Ctrl-b "Split top and bottom
Ctrl-b arrowMove between panes
Ctrl-b zZoom a pane to full size and back
Ctrl-b xClose the pane
Ctrl-b SpaceCycle pane layouts
Ctrl-b [Scroll mode (q to leave); search with / in vi mode
Ctrl-b :setw synchronize-panes onType into every pane at once
Ctrl-b sSwitch between sessions
Ctrl-b $Rename session
Ctrl-b ?List all key bindings
set -g mouse on~/.tmux.conf: click, resize and scroll with the mouse
set -g history-limit 50000~/.tmux.conf: longer scrollback
setw -g mode-keys vi~/.tmux.conf: vi keys in scroll mode
tmux source-file ~/.tmux.confReload the config

Ctrl-b is the default prefix: press it, release, then the key. The point of tmux on a server is that a session survives a dropped SSH connection, so a long migration or backup started inside one keeps running. Many people rebind the prefix to Ctrl-a in ~/.tmux.conf.

Why use it on a server

A tmux session keeps running when the SSH connection drops. A database migration, a long backup or a big rsync started inside tmux survives a laptop going to sleep, and you reattach with tmux attach. Panes put a log tail next to the command you are running. The tmux wiki has the full reference.

The prefix

Every binding starts with the prefix key: press Ctrl-b, release, then the key. Many people rebind it to Ctrl-a in ~/.tmux.conf; GNU screen users find that familiar.

Share

Frequently asked questions

How do I reattach to a tmux session after disconnecting?
tmux ls to list sessions, then tmux attach -t name, or tmux a to attach to the most recent one.
How do I scroll up in tmux?
Press Ctrl-b [ to enter copy mode, scroll with the arrow keys or Page Up, and press q to leave. set -g mouse on enables the scroll wheel.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools