47

I usually connect to remote linux servers from a specific windows server (W1). On the Windows side, I use putty and on the linux side, I start tmux.

Occasionally, I have to use a different windows server (W2) and connect to the same tmux sessions.

Problem: If I had set a size for the putty windows on W1, then I can not exceed this size on W2. When I maximise the putty window, the extra space is unusable, filled with ~ characters.

Is there a way to "force" resize on W2, even if that means W1 will show only partial output ? Or a way to make W1 get disconnected from tmux session ?

3 Answers 3

63

With tmux list-client, you can list all clients connected to tmux sessions. For instance:

$ tmux list-client
/dev/pts/6: 0 [25x80 xterm] (utf8)
/dev/pts/8: 0 [25x80 xterm] (utf8)

From this point, you can choose to detach a specified client, or all clients of a specified session. Say I want to detach everyone connected to session 0:

$ tmux detach-client -s 0

Then, you can attach the session so the size will be yours.

Actually, all that can be done with tmux attach -d (the -d option force all other clients to detach).

5
  • 3
    Cool !! "-d" is exactly what I wanted !!
    – Prem
    Jul 28, 2015 at 11:54
  • 2
    Thanks, in my case it was tmux detach-client -t /dev/pts/X I was looking for.
    – bufh
    Nov 10, 2016 at 12:08
  • 1
    a shortcut to the verbose 'list-client' is: tmux ls Nov 18, 2016 at 13:01
  • 3
    matias, actually "tmux ls" is a shortcut for "list-sessions"
    – Matt
    Aug 8, 2017 at 13:23
  • For tmux attach -d, you can use it from within the tmux session by doing <c-b> :attach -d or outside with tmux attach -d -t <session_name>
    – divibisan
    May 19, 2020 at 14:44
35

It is not necessary to detach the other sessions. Use

<c-b>:resize-window -A

to grow the window to the largest connected session.

Other useful parameters to resize-window (resizew) are:

  • -a: resize to the smallest session.
  • -U, -D, -L and -R: adjust up, down, left or right, respectively. Can be followed by a number, determining how much to grow (-D and -R) or shrink (-U and -L).
  • -x <width> and/or -y <height> set width and height to the given values.
3
  • 1
    Unknown command: resize-window Jan 8 at 18:23
  • @onlinespending Same here, tmux 2.7, default centos stream 8
    – Alexis
    Mar 3 at 12:05
  • @Alexis yeah. I needed to update my tmux. I used linux brew since I don't have root access on my work machine Mar 3 at 19:54
16

if you are already in tmux then you can detach all other connections using :detach-client -a. It leaves your current session only. Consequently you won't have extra space is unusable, filled with ~ characters.

3
  • 2
    +1 ! This way, we do not have to exit and connect again !
    – Prem
    Oct 18, 2018 at 14:52
  • Will this work very well on old ubuntu 18.04.5 LTS and with old TMUX Client. Thanks sir Aug 23, 2021 at 14:01
  • @BenyaminLimanto , Yes , it will work with Ubuntu 18.04.5 LTS having TMUX client ; My Question was itself asked much earlier in 2015 & the given solutions did work !
    – Prem
    Dec 22, 2021 at 7:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.