How to kill all tmux sessions (or at least multiple sessions) from the (Ubuntu) CLI?

When I do ps aux | grep tmux I see 3 processes:

UU      2970  0.0  0.0  19556  1228 pts/0    S+   02:48   0:00 tmux
UU      3445  0.0  0.0  12944   988 pts/5    S+   03:31   0:00 grep --color=auto tmux
UU     27557  0.0  0.2  29788  4840 ?        Ss   Jan04   0:02 tmux

How could I kill all of these at once (or at least some of them, selectivity) ?


You can use tmux kill-server to cleanly and gracefully kill all tmux open sessions (and server).

If you are inside a tmux session you would like to keep, use tmux kill-session -a to close all other sessions.

To close a specific session, use tmux list-sessions to identify the session you want to kill, and then use tmux kill-session -t targetSession to kill that specific session.

Also you can grossly kill all tmux processes with pkill -f tmux.

Hope it helps.

  • 2
    ps aux | grep tmux after tmux kill-server still shows a tmux process... Same goes with pkill -f tmux as in my answer. Can you explain this? Thanks,
    – user423047
    Jan 5 '17 at 6:20
  • 2
    @Benia are you sure you are not just seeing the grep tmux process (which is included in the ps output of your original question)? Jan 5 '17 at 13:45
  • 4
    If you issue ps aux | grep blablablawhichdoesntexist it will always show at least one line, corresponding to the grep blablablawhichdoesntexist command.
    – dgonzalez
    Jan 5 '17 at 14:14
  • 1
    Are you missing -t flag, cos it shows error without -t flag set for killing a particular session. Usage: kill-session [-a] [-t target-session] Nov 1 '17 at 3:03
  • 1
    It used to be very painful tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
    – Foad
    Feb 1 '18 at 14:35

I can kill all of these processes with the command:

pkill -f tmux

It kills all processes (full list) of the matching name (tmux).

Note for newcomers: This way could serve you to kill all process of other matching names.


This would list and kill all the sessions:

tmux list-sessions | awk 'BEGIN{FS=":"}{print $1}' | xargs -n 1 tmux kill-session -t
  • to others who might run into this (like me) - if you're on a tmux session running this, you might want to kill all the other sessions first before killing your own :P
    – Ho Man
    Aug 23 at 19:39


# tmux ls
session-0a: 1 windows (created Sat Dec  5 02:31:35 2020) [117x30]
session-84: 1 windows (created Sat Dec  5 01:55:18 2020) [190x47] (attached)
session-b3: 1 windows (created Sat Dec  5 03:23:44 2020) [94x13]
session-b2: 1 windows (created Sat Dec  5 02:45:00 2020) [104x14]
session-ae: 1 windows (created Sat Dec  5 01:55:18 2020) [190x47] (attached)

This will kill all sessions not attached by someone:

tmux list-sessions | grep -v attached | awk 'BEGIN{FS=":"}{print $1}' | xargs -n 1 tmux kill-session -t || echo No sessions to kill


  1. https://stackoverflow.com/questions/10411616/grep-regex-not-containing-string
  2. https://unix.stackexchange.com/questions/33049/how-to-check-if-a-pipe-is-empty-and-run-a-command-on-the-data-if-it-isnt
  3. How to kill all tmux sessions (or at least multiple sessions) from the CLI?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy