How to disconnect all other tmux users

Tmux is one of the most useful tool when it comes to using our terminals. One of the most frustrating thing is when many users attach to your tmux session and you have lost complete control of the situation. Worry not, there is a way to disconnect all other tmux users from the session, when you can be your tmux session's ruler.

You can use <prefix> D to choose choose the client you want to detach. This will also list the clients and when was the last time they used it.

Please note- Use CAPITAL LETTER 'D' (shift + d)

Details of the option-

detach-client [-P] [-a] [-s target-session] [-t target-client]
               (alias: detach)
         Detach the current client if bound to a key, the client specified
         with -t, or all clients currently attached to the session speci-
         fied by -s.  The -a option kills all but the client given with
         -t.  If -P is given, send SIGHUP to the parent process of the
         client, typically causing it to exit.

In a tmux session, tmux detach-client -a will detach all other clients except the current one.

You can also create a function in your ~/.bashrc -

detach_others () { tmux detach-client -a;}

So you can simply call detach_others from your terminal, and all other sessions will be detached.