What is a tmux cheatsheet?
tmux is a terminal multiplexer. It lets you keep several terminals inside one window, split the screen into panes, and, most importantly, leave a session running on a server while you disconnect. You close the laptop, the SSH connection drops, and when you attach again the build, the editor and the logs are exactly where you left them.
Most tmux commands are keys pressed after a prefix. The default prefix is Ctrl+B: press it, release it, and then press the next key. So Ctrl+B d means hold Ctrl and press B, let go, then press d. This sheet writes it that way. The commands that you type in the shell, such as tmux new -s <name>, are listed separately from the keys you press inside tmux.
The six sections are: sessions from the shell, sessions inside tmux, windows, panes, scroll and copy mode, and configuration for ~/.tmux.conf. A session holds windows, and a window holds panes; keeping that hierarchy in mind makes the rest easy. Placeholders appear between angle brackets, such as <name>; replace them. The page runs in your browser, with no account and nothing sent. For the other half of working on servers, see the Linux cheatsheet.
How to use the tmux cheatsheet
- Open the page and scroll, or use the section chips at the top to jump to Panes, Windows or Configuration.
- Type in the search box to filter. It looks at the description, the section title and the commands, and every word has to match, so
split panefinds the items about splitting. Capital letters and accents are ignored. - Press
/anywhere on the page to focus the search box. - Click the copy button next to an item to copy its command or key sequence. When an item has several commands, they are copied together, one per line.
- Use the Copy section button in a section title to take all the commands of that group. In Configuration this gives you lines ready to paste into
~/.tmux.conf. - Click Print for a paper or PDF version, without the buttons.
- Start a session in the terminal, then use the keys after the prefix.
To check which processes keep a session busy, see the Linux cheatsheet and, for another terminal editor, the Vim cheatsheet.
Examples
Keep a job running after you disconnect
tmux new -s buildRun your long command inside it. Then press Ctrl+B, release, and press d to detach. The command keeps running. Later, from any new SSH connection:
tmux ls
tmux attach -t buildbuild: 1 windows (created Sat Nov 22 09:14:02 2026)You are back in the same screen. tmux new -As build does both: attaches if the session exists and creates it if not.
Split the screen for code and logs
Inside tmux, press Ctrl+B % for a left and right split and Ctrl+B " for a top and bottom split. Move between panes with Ctrl+B and an arrow key. Ctrl+B z zooms the current pane to the whole window and a second press brings the layout back, which is handy to read a long log.
Scroll back through the output
Ctrl+B [ enters copy mode, where the arrows and PageUp scroll the history. Press q to leave. With the vi keys enabled, / searches forward, Space starts a selection and Enter copies it, and Ctrl+B ] pastes it.
A small configuration
Add these lines to ~/.tmux.conf:
set -g mouse on
set -g base-index 1
setw -g mode-keys vi
set -g history-limit 50000Then reload it without restarting:
tmux source-file ~/.tmux.confThe mouse now selects panes and scrolls, windows start at 1, copy mode uses vi keys and you keep 50000 lines of history.
Common errors and how to fix them
- The prefix does nothing:
Ctrl+Bis a separate step. Press it, release it, then press the key. Pressing everything together does not work. - no sessions or no server running: nothing is running.
tmux attachhas nothing to attach to; start one withtmux new -s <name>. - sessions should be nested with care, unset $TMUX to force: you ran
tmuxinside tmux. Detach first withCtrl+B d, or useCtrl+B sto switch sessions instead of starting another. - Closing the terminal window killed the work: you did not use tmux, or you ran
exitin the last pane, which ends the session. Detach withCtrl+B dinstead of closing. tmux kill-serverclosed everything: it ends the server and every session. To end one, usetmux kill-session -t <name>, andCtrl+B &to close one window orCtrl+B xfor one pane, both ask first.- Mouse selection does not copy to the system clipboard: with
mouse on, tmux takes over the mouse. Hold Shift (Option on some macOS terminals) while selecting to use the terminal's own selection. - The config change has no effect: reload with
tmux source-file ~/.tmux.conf. - No command matches your search: remove a word. All words must match at once.
Frequently asked questions
How do I detach from tmux and come back later?
Press Ctrl+B, release, then d. The session keeps running. List sessions with tmux ls and attach with tmux attach -t <name>, or just tmux attach for the last one.
How do I split the screen in tmux?
Ctrl+B % splits into left and right panes, and Ctrl+B " into top and bottom. Close a pane with exit or Ctrl+B x.
How do I change the prefix from Ctrl+B to Ctrl+A?
Add set -g prefix C-a, unbind C-b and bind C-a send-prefix to ~/.tmux.conf and reload it.
How do I scroll in tmux?
Enter copy mode with Ctrl+B [ and use the arrows or PageUp. Quit with q. With set -g mouse on the mouse wheel also scrolls.
What is the difference between a session, a window and a pane?
A session is the whole workspace that you can detach and attach. A window is like a tab inside the session. A pane is a split of one window.