Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not new to Linux, but there's this strange behaviour I'm seeing on my Fedora 15 box. I want to add the superuser to a group called, say, thisgroup.

# usermod -a -G thisgroup root
# groups
# root bin daemon sys adm disk wheel

^^ thisgroup is absent. Surprisingly, when I thought of editing /etc/group, root was present there!

Anyone on why groups didn't show my new addition?

share|improve this question

migrated from Jul 4 '11 at 19:31

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

From the manpage of the groups command:

Print  group memberships for each USERNAME or, if no USERNAME is speci‐
fied, for the current process (which may differ if the groups  database
has changed)

This is exactly your case: the group database has changed, but the group membership for the current process hasn't been updated. If you instead queried the group memberships for the root user you would have got the correct result.

matteo@teomint:~$ sudo usermod -a -G test matteo
matteo@teomint:~$ groups
matteo adm dialout cdrom plugdev lpadmin admin sambashare
matteo@teomint:~$ groups matteo
matteo : matteo adm dialout cdrom plugdev lpadmin admin sambashare test

Long story short: for the current process, root isn't member of thisgroup yet; you have to login again.

share|improve this answer
Thanks. I was wrong. Everyone is new to Linux, except the "Man" – yati sagade Jul 4 '11 at 19:44
Thanks. It didn't work without logging out and logging in. – Maksim Dmitriev Jan 15 '14 at 12:37

You need to logout and in again - with no argument the groups command prints the groups that the current process has which doesn't change when when you change the group database.

If you do groups root then you should see it listed as that consults the /etc/group file.

share|improve this answer

You must log in to answer this question.

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