1

Really simple, I run the following in Ubuntu 14.04 Server, logged in as max:

sudo usermod -a -G www-data max

When I run groups as max after doing so, www-data is not in the output set of groups.

Any idea what could cause this?

1
  • Another note, I tried sudo adduser max www-data and got the user 'max' is already a member of 'www-data'. This appears to be true when I groups max, but not when I groups as max. Bizarre! This is still troublesome since max is unable to chgrp files to www-data without sudo. (yes I understand the implications of non-sudo chgrp, no lecture necessary)
    – M-Pixel
    Dec 20, 2014 at 16:52

2 Answers 2

3

Log out and back in again, or in some cases, you need to reboot your system.

Adding a user to a group doesn't take effect until then.

0

I assume they are correct and you did not logout/in or reboot...

It is best to get into the habit of restarting or at least logging out and then back in when manipulating users/groups/permission.

Many novice users (even some advanced users :) ) are guilty of not doing this, so when that happens you run into issues that make it seam that the modification did not take, than more often than not users wind up making a mess out of the situation trying to fix a problem that doesn’t even exists. Then when the eventually reboot... "WTF happened? $*^#ing Linux..."

Sometimes, after making a mod to part of the system and simply restarting the services effected by those mods is enough to get everything working, other times it is not. Each case/command procedure is different, also Linux being what it is, there is more than one way to skin a cat, and each way is slightly different. While the end result may be the same, the way you got there will differ and each command acts in its own way, and command defaults can vary widely!

Also do a little more reading than typing in the first command that comes back from your "How to add a user to a group?" gSearch. It is always best to refer to your distros documentation, some distros may handle some commands slightly different than other, or you may misunderstand what a command actually does if you just glance through the man pages. eg.: I want to add existing user "john" to group "others", the following two commands will accomplish this:

sudo usermod -a -G others john
sudo usermod -g others john

But with subtle differences than a user may not understand. In this case,

1st command adds the group "others" to "johns" supplementary (secondary) groups.

2nd command adds and sets "johns" primary group to "others".

So technically both add "john" to "others" but in different ways. Basically what it comes down to in the end is RTFM. :) Information is your friend, If you read your may through 10,000 word manpage in 5 seconds yea you may get the command to accomplish what you want, but it also may do things you don’t know/understand that may cause you an issue down the road, and that is no ones fault but your own.

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.