25

I'm trying to add myself to the fuse user group but it doesn't look like the change is taking effect even though /etc/group looks correct after invoking addgroup or usermod.

I've tried both ...

sudo addgroup fjohnson fuse

and

sudo usermod -a -G fuse fjohnson

/etc/group shows the change

fuse:x:104:fjohnson

but I can't read

-rw-r----- 1 root fuse 215 Oct 16 10:39 /etc/fuse.conf

as

cat: /etc/fuse.conf: Permission denied

and groups(1) returns

fjohnson adm dialout cdrom plugdev lpadmin admin sambashare
5
  • 9
    Have you logged out and logged back in after the change? Oct 16, 2013 at 15:02
  • 3
    See this as well.
    – Joseph R.
    Oct 16, 2013 at 15:09
  • @esnyder- I've got too many things open to do that. Any idea why that would work? (It sounds like it would from what I have been reading)
    – fthinker
    Oct 16, 2013 at 15:22
  • @esnyder,@Joseph R. - I've upvoted both of you since your comments were both correct.
    – fthinker
    Oct 16, 2013 at 15:37
  • 1
    Something related that tripped me up briefly was using ssh ControlMaster to log into all my boxes. Logging out and back in is insufficient to refresh groups as the session is effectively kept open. In this case you need to log out, "ssh -O exit <host>" and log back in. Feb 7, 2020 at 22:36

1 Answer 1

28

When you add a group to a user, this user should logout/login in order for the change to take effect.

You can also use newgrp command.

  $ id
  uid=1000(romain) gid=1000(romain) groups=1000(romain),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),105(scanner),110(bluetooth),112(netdev)
  $ sudo addgroup romain fuse
  Adding user `romain' to group `fuse' ...
  Adding user romain to group fuse
  Done.
  $ id
  uid=1000(romain) gid=1000(romain) groups=1000(romain),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),105(scanner),110(bluetooth),112(netdev)
  $ newgrp fuse
  $ id
  uid=1000(romain) gid=103(fuse) groups=1000(romain),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),103(fuse),105(scanner),110(bluetooth),112(netdev)
4
  • 9
    Note that the effect of newgrp fuse is not to let "Adding user romain to group fuse" to take effect, the effect is that the primary GID of the user changed which is fundamentally different - e.g. newly created files will have gid=103 rather than gid=1000. May 26, 2018 at 21:30
  • 9
    This is answer is not what i was looking for. im having same issue, when i add user to a group, it shows in /etc/group but doesnt show in groups, i have exited, logged back in, still not showing. I do have ssh multiplex on, i wonder if thats it, however I feel as if exiting should be enough. This is for Centos6, and this problem is consistent across multiple servers. newgrp just seems to be a temp workaround, where i want to set user perms, and want to make sure its working right. Jun 18, 2018 at 17:43
  • 2
    @JakubKlinkovský - call newgrp fuse then newgrp romain, as discussed in detail in this answer - unix.stackexchange.com/a/613608/247579 Oct 9, 2020 at 11:56
  • 2
    @BrianThomas - 'newgrp' opens a new shell, and in that shell the new group shows in groups. It is true that if you leave that shell, the effect is reversed without side effects. If that is not enough and you are looking for alternative to reboot (because logout doesn't work) then try looking at the second part of my answer unix.stackexchange.com/a/613608/247579 , where I discuss killing a user process titled (sd-pam) which uniquely didn't get killed by the logout. May be related to systemd. Worked for me in ubuntu 20.04. Oct 9, 2020 at 12:47

Not the answer you're looking for? Browse other questions tagged .