useradd and the default group

Cameron Simpson cs at zip.com.au
Mon Apr 13 18:29:41 UTC 2009


On 13Apr2009 16:28, Carl D. Roth <roth at ursus.net> wrote:
| Can some one explain the following weird behavior with useradd?
|   # useradd -g mock -r -m -d /var/lib/mockuser mockuser
|   --> create a new 'mockuser' user that can be used to run /usr/bin/mock
|   # id mockuser
|   uid=494(mockuser) gid=491(mock) groups=491(mock)
|   # grep mock /etc/group
|   mock:x:491:roth
| Hm, that's interesting, 'mockuser' is not in the 'mock' group.  This can 
| be verified using 'getgrent()'.

If you look at /etc/passwd you will see the gid field there is "mock"
(494). Eg:

  $ grep cameron /etc/passwd
  cameron:x:1000:1000::/home/cameron:/bin/zsh

The -g option to useradd specifies the primary group, which is recorded
in the passwd file, not the group file. A UNIX user has a primary group
which comes from the passwd file and secondary groups which come from
the group file. Absent the setgid bit on a directory, new files and
directories a process makes get their group ownership from the primary
group. _Access_ (open, cd, etc) is governed by uid and all the groups.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Drive Agressively  Rash Magnificently   - Nankai Leathers




More information about the fedora-list mailing list