1

I just did this "mistake" and it took me a while to figure it out! Can anybody explain me what happens behind the scenes of this "bug"? Thanks in advance :)

  • Out of interest, which Linux distribution (or Unix version) did you discover this on? – roaima Apr 29 '18 at 6:51
3

This is really just how your distro had packaged sudo.

There's nothing special about the sudo group, it's just a normal Linux group.

The power of the sudo group comes from being listed in /etc/sudoers(.d) as being allowed to elevate to root for any commands.

There are a couple things that is necessary for sudo to work:

  1. sudo executable needs to be setgid
  2. your user or a group your user is in must be listed in /etc/sudoers.d
  3. your user must be logged into the group when running sudo

If either of these is untrue, for example, if your distro recreated the sudo group, for example because it wants the sudo group to have a specific gid, while installing sudo for the first time, then it's possible that your sudo won't work.

Another common mistake is that right after adding a user to a group, your existing process won't have the new permission immediately, you'll need to either use grp or restart the login shell to get the permissions of the new group.

  • In fact, I accepted this question cause it sound informative to me. But the real case was that when you add a user to a group, changes will take effect from the next time he logs in. – JAAAY Apr 29 '18 at 8:31

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.