If I connect to a tmux session with the tmux a command, I end up sharing the session with a friend and we cannot work on our own thing (since we have to work in different windows). On the other hand, if I connect with tmux a -d, my friend's session is detached and he (or rather, one of us) can't work on the server.

I'm aware that this functionality might go against the 'aim' of tmux, but I thought I should ask none-the-less. Is there anyway that me and my friend can use the same tmux session on the server and work in different windows at the same time?

1 Answer 1


Use “Grouped Sessions”

Instead of attaching to a session, you can create a “grouped session” by giving -t to new-session:

tmux new-session -t 'original session name or number'

Sessions that are grouped always have the same windows (new (closed) windows are linked into (removed from) all the session in the group), but they each have their own session options, including the current and previous window values.

If you and your friend each work in a session that is part of the the same group, then you can each work in different windows but still have easy access to the same set of windows, or even work in the same window (if that is appropriate).


Create an initial session:

tmux                     # start initial session, lets say it gets the name '3'

To keep it clear who should use each session, you should will probably want to give each session a mnemonic name. I will use his and mine below, but you will probably want to use something based on your real names, nick names, login names, or something else equally identifying.

Rename this original session as his and (outside of the original session) create a grouped session named mine:

tmux rename-session -t 3 his
tmux new-session -d -t his -s mine          # leave off -d to attach right away

When you want to attach to your clone of “the session”:

tmux attach-sesssion -t mine

When your friend wants to attach to his clone of “the session”:

tmux attach-session -t his

You can kill-session either session and the other will survive. You have to kill all of the sessions in a group before their windows will be forcibly closed.

tmux Command Abbreviations

If you are scripting the tmux commands, it is probably best to use the full command names (as above) to avoid ambiguity and aid in “self documentation”. If you are typing them you can use abbreviations:

  • new-session: new, or new-s, new-se, new-ses, …
  • rename-session: rename, or rename-s, rename-se, rename-ses, …
  • attach-session: a, at, …, attach, attach-, attach-s, …
  • kill-session: kill-ses, kill-sess, …

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.