Kill tmux sessions
March 18, 2020 ‐ 2 min read
When you detach from a tmux session it keeps running, so you can reattach to it later again. However, if you don't need the session again you might as well close it for good. You can do this by killing the session.
To kill a tmux sessions you use the
tmux kill-session command. If you don't specify a session tmux will kill the current or last active session. Depending on if you're currently in an active tmux session or not.
$ tmux kill-session
A session to kill can be specified by using the
-t option and use the session name as its argument.
$ tmux kill-session -t session_one
Kill all tmux sessions
The easiest way to kill all tmux sessions isn't with the
kill-session command. To kill all tmux sessions at once you can use the
kill-server command. This command will besides killing all the sessions also shut down the tmux server.
$ tmux kill-server
Kill all other tmux sessions
kill-session command has the option to kill all session except a specified one. For this you'll need to use the
In case you want to kill all tmux sessions except the current one you don't need to specify a session name. Or if you're outside of tmux, tmux will assume you want to kill the last active session. See the command below to kill all other tmux sessions.
$ tmux kill-session -a
If that isn't what you want you can specify the session name yourself. For this you'll have to use the same
-t option as before.
$ tmux kill-session -at pumpkin_session
A great resource for learning more about tmux are its man pages. You can read them online here or from the command-line using the following command:
$ man tmux
Or take a look at this book: