I am SSH'ing into a debian server, and to avoid having multiple connections at the same time, I use tmux.

I changed the permissions of a directory (here, /opt/syncserver), and set the owner to the group and user www-data. The permissions of this directory are equivalent to 770 in chmod, which means rwxrwx--- (read/write/exec to owner and group).

I then added the main user (that we will call user1 here) to the group www-data, because he wasn't in it previously. I then tried to cd into the newly modified directory, without success (Permission denied error).

Creating a new shell in the same tmux session does not solve the problem either as it should (see the probable duplicate of this question).

I tried launching another SSH session, still with the same user, and had no problem going into the directory.

How can new shells created in a tmux session not take in account the modifications of permissions ? Is there a way to fix this, or am I just completely mistaken and did something wrong at the beginning ?

Creating a new tmux session (with the other one still attached) does not solve the problem either. I guess restarting completely tmux should solve the problem, but I would like to avoid this and to know why does this happen.

  • My question is not only about how to not reboot, but also about why does tmux not perform a new login each time a new shell is opened ? – cocosushi Apr 1 '17 at 21:41
  • The answer to the question you point to seems legit, but it is solved simply by relogin in/reopening a new shell, which I have done in my case in tmux, but doesn't work. – cocosushi Apr 1 '17 at 21:46
  • You don't have to SHOUT OUT that you "EDIT"-ed your text. Just improve the text by incorporating your changes in a single comprehensive text. Any interested in what changed can go to the edit history. – Anthon Apr 2 '17 at 8:02
  • Yes, sorry for that – cocosushi Apr 2 '17 at 9:17

How can new shells created in a tmux session not take in account the modifications of permissions ?

The uid, gid, and supplementary groups associated with a process are only reset at login time. New shells created in a tmux session are not new logins, they're just new children of the tmux process.

To get your group memberships updated, you have to re-login, or use one of a very small set of commands (newgrp, su, sudo) that will start subshells with re-initialized groups (but those commands won't help you re-initialize the credentials of an already-running process like tmux).

| improve this answer | |
  • In a quick test on a debian box, I was able to: (1) log in, (2) create a new group, (3) usermod -G add the group to my account, and (4) run newgrp to add that group to my existing login. Not much help as it still requires a restart of tmux, but it's short of a full re-login. – Jeff Schaller Apr 2 '17 at 13:12
  • Thank you very much for your answer, it's precise and clear :) Now I understand why this does not work, I think @JeffSchaller 's solution is a good work-around too. – cocosushi Apr 2 '17 at 13:22
  • Ah yes, good point @JeffSchaller about newgrp. su would also work. Let me edit that in. – Celada Apr 2 '17 at 17:46

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