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

Im not sure why the following have different output. My understanding is that groups without specifying a user give all the groups the currently logged in user is a member of.

jacob@box:~$ groups
jacob adm lp dialout cdrom plugdev lpadmin sambashare

jacob@box:~$ groups jacob
jacob : jacob

Also what does it mean "groups of the current process" (from the groups man page)? Where are they set up?

share|improve this question

migrated from Jun 8 '11 at 18:07

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

Which distro is this ? – cnicutar Jun 8 '11 at 17:43
It is a Ubuntu distro. – Jake Jun 8 '11 at 17:55
@Jake Try logging out and then back in. – cnicutar Jun 8 '11 at 17:58

Just as every process has a current real and effective user ID, and a real and effective group ID, it also has a list of supplementary groups. These are numbers (not names) all maintained by the kernel. They are set by the login process (or display manager) when you log it, just like your user ID. They are inherited by sub-processes, just like your user ID.

When you run groups with no arguments, it ultimately invokes getgroups() to obtain the supplementary group list from the kernel. (On my Linux system, /usr/bin/groups is a shell script that runs "id -Gn", which in turn invokes getgroups().)

When you run groups username, the command has to "guess" what the supplementary groups will be when that user logs in. It generally does this by reading /etc/group or talking to NIS or talking to nscd or... Well, there are a lot of ways it might work.

What you are observing is similar to discovering that your current real user ID and your entry in /etc/passwd are inconsistent. This means there is something a little odd about your system's configuration, but it is hard to say what without more investigation.

share|improve this answer

It could be one of the following:

  • It could be a bug (although I doubt it)
  • You may need to logout and login again

The groups are set in the /etc/group.

share|improve this answer

You must log in to answer this question.

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