Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Jul 4 '11 at 19:31

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

2 Answers 2

up vote 4 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 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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