How to kill a tmux session, or the whole server?

By Romain Dorgueil

Short answer

tmux kill-session -t name      # kill one session
tmux kill-session -a -t keep   # kill ALL sessions except 'keep'
tmux kill-server               # kill everything: all sessions, the server itself

Details

kill-session -t name terminates one session and every process running in it. Detaching (prefix d) keeps the session alive in the background; killing does not.

The -a flag inverts the target: kill-session -a -t keep kills every session except keep. Handy to clean up after a few days of tmux new enthusiasm while keeping the one you are working in.

kill-server is the nuclear option: it terminates the server and all sessions with it. Since the server starts on demand, the next tmux new starts fresh.

To kill less than a session: prefix x kills the current pane (with confirmation), prefix & kills the current window.

Verified on tmux 3.2a: after kill-session -a -t sess2, only sess2 is left.