How to Kill All the Tmux sessions?

The terminal multiplexer program allows multiple users to work on different tmux sessions terminals simultaneously that connect to form a single terminal Tmux. Every session can open multiple windows called panes, and with tmux, you can switch between different programs using a single terminal.

You may need to kill all the tmux sessions if you want to stop all the processes running within the tmux sessions.

This post will illustrate the possible methods to kill all tmux sessions. This guide with examples using the below-helping topics:

Let’s start with the basics of tmux session.

Method 1: Using the pkill Command

The pkill command can be utilized with the “f” (full) option, which kills all the Tmux sessions with a single command. Before killing all the sessions, let’s list the currently running tmux session by using the below command:

$ tmux ls

The output shows that three tmux sessions are in progress named “0”, “2” and “4”.

To kill all the currently active sessions, including the session in which we are working, the following command is executed in the tmux session:

$ pkill -f tmux

After running the pkill command, all the sessions are killed, it shows the status “terminated” on all the tmux sessions.

The tmux sessions that are killed can be verified by running the following “ls” command:

$ tmux ls

It shows that all the tmux sessions are killed, and no tmux server is currently running.

Method 2: Using the kill-server Command

The kill-server allows the users to kill every open tmux session at once. For instance, two sessions are currently active, as seen with the “ls” command, and to kill both sessions, use the below kill-server command:

$ tmux kill-server

After running the kill-server command, every active session is closed, including the session in which we were working and shows that status “server exited”.

The output verifies that every tmux open session is killed.

Method 3: Kill All Tmux Sessions Excluding the User Working Session

The previous method kills all the Tmux sessions, including the current user working session, and you are exited out of that session as well. Suppose you want to kill all the sessions except the session in which you are working. In that case, the below “kill-session” command is executed:

$ tmux kill-session -a

The above output shows that all other sessions other than the session working tmux session are closed.

Method 4: Kill the Tmux Processes to Kill All the Tmux Sessions (GUI)

To kill specific, or all the Tmux processes that run the Tmux sessions can be killed using the Graphical User Interface GUI method by performing the following steps:

Press the “Windows + a” shortcut keys to open the applications search bar and search the “system monitor”. Click on the system monitor icon to start it:

The system monitor application will open, and you will be in the “Processes” tab by default. Now, click on the search icon and search “tmux” in the processes tab search bar. All the Tmux processes will be shown in the window:

The output shows three tmux sessions (client side) are currently active with a single tmux server process.

Select all the tmux processes by entering the shortcut “Ctrl + A” and the “Ctrl + k” shortcut to kill all the sessions directly.

After selecting all the processes, press the mouse’s right button to option the list of options. Select the “Kill” option to kill all the Tmux processes that will kill all the active sessions.

After choosing “Kill” or pressing “Ctr; + K”, you will be shown the below confirmation prompt. Select the “Kill Processes” to close all the Tmux sessions:

All the Tmux processes associated with the active Tmux sessions are closed that, kills all the sessions:

These were all the methods to kill all tmux sessions.

Conclusion

The Tmux sessions in Linux perform different functions using a single Terminal multiplexer (tmux) which can be killed separately and combined. All the Tmux sessions can be killed using the “pkill -f tmux” and “tmux kill-server” commands. Moreover, the system monitor application can manually kill a single tmux session or all Tmux sessions.