如何断开tmux中的所有其他用户?

Dre*_*eur 200 tmux

我有一个tmux会话,窗口太小,因为某个用户在某处连接.

如何告诉tmux断开所有连接的用户?

dem*_*ure 286

您可以使用<prefix> D (C-b默认情况下为prefix ),以选择要分离的客户端; 它还会列出col/lines以及上次使用的时间.注意大写D,即Shift+ d.

你也可以使用tmux的detach-client选项

 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.
Run Code Online (Sandbox Code Playgroud)

从tmux里面的命令行<prefix>:跟随detach [options]或者tmux detach [options]

  • `<prefix> D`小心,**majuscule D**在这里很重要!! (在实现它之前,我花了一些令人沮丧的时间分离我现在的客户:D) (14认同)
  • 在tmux会话中,`tmux detach-client -a`将分离除当前客户端之外的所有其他客户端.我经常输错`prefix-D`所以我更喜欢这种方法.我甚至有一个函数`detachothers(){tmux detach-client -a; `. (7认同)
  • 谢谢.我通常[Ctrl-b] [D] [向上] [输入] (5认同)
  • ...如果您以前没有遇到过这个词,“majuscule”的意思是“大写”。 (3认同)
  • @AlexanderChzhen 按一下“q”即可退出选择菜单,而无需选择要结束的会话。 (2认同)

小智 143

tmux a -dt <session-name>

a=attach
d=detach other clients (so only you can attach to this session)
t=target
Run Code Online (Sandbox Code Playgroud)

  • tmux a -d为我工作 - 谢谢! (12认同)

Cor*_*mer 12

我将把@PEdroArthur的精彩评论分解成一个单独的答案,因为它直接回答了最常见的用例:“在 tmux 会话中并希望断开所有其他会话”

从tmux 会话运行此命令:

tmux detach-client -a
Run Code Online (Sandbox Code Playgroud)