tmux in 5 Commands

tmux keeps your terminal programs running after you close the window or lose the connection. Learn the five commands you need, plus panes and scrolling.

Checked against official docs on 12 Oct 2026

On this page

tmux is a free program that keeps terminal programs running in the background. You start a session (a named workspace) in tmux, then you can leave it and come back later. Everything inside keeps running, even when you close the window or your connection to a server drops. That is why people run AI assistants on a server inside tmux.

tmux runs on Linux and on macOS. On a server, install it with the package tool of the server. The tmux project lists, for example:

SystemInstall command
Debian or Ubuntuapt install tmux
Fedoradnf install tmux
macOS with Homebrewbrew install tmux

On many servers you must add sudo before apt or dnf (it runs the command as the administrator).

1. Start a named session

tmux new -s work

work is a name that you choose. A green status line appears at the bottom of the window. You are now inside tmux. Start your assistant here, for example with claude, codex or gemini.

2. Leave the session running (detach)

Press Ctrl + B, let go, then press D.

tmux shows [detached (from session work)] and you are back in the normal terminal. Your session and the assistant in it keep running. You can now close the window or disconnect.

All tmux keys work this way: first Ctrl + B (the prefix key), then one more key.

3. List your sessions

tmux ls

You see each session name, the number of windows and when you made it.

4. Go back into a session (attach)

tmux attach -t work

You see the session exactly as you left it. tmux attach with no name goes back to the most recent session.

5. End a session

tmux kill-session -t work

This closes the session and every program in it. Stop your assistant properly first. You can also type exit in the last window of a session to end it.

Extra keys: windows, panes and scrolling

KeysWhat they do
Ctrl + B, then COpens a new window in the session
Ctrl + B, then NGoes to the next window
Ctrl + B, then %Splits the window into a left and a right pane
Ctrl + B, then "Splits the window into a top and a bottom pane
Ctrl + B, then OGoes to the next pane
Ctrl + B, then [Scrolls back: use the arrow keys, then press Q to stop
Ctrl + B, then ?Shows all keys (press Q to close)

A pane is one part of a split window. Use one pane for the assistant and one for your own commands. Scroll back to read what the assistant did while you were away.

To run an assistant on a server with tmux, follow Run an assistant on a server.

Sources