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.

Is it possible for a user to belong to a group in Linux but that the group name is not listed in the group file in /etc directory. If so, what are some examples?

share|improve this question

migrated from stackoverflow.com Dec 25 '12 at 2:39

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

add comment

3 Answers

Group memberships might be defined in NIS instead of /etc/group. Consult your /etc/nsswitch.conf.

share|improve this answer
add comment

It is possible to have a file that has a GID that isn't listed in groups, this quite often happens if you import files (e.g. tar-balls) from another machine. The group is then shown by ls and such as a number, e.g. 4000. For example

-rw-r--r-- 1 root 4000 0 Dec 24 11:04 foo.foo

(I did this by touch foo.foo; chgrp 4000 foo.foo)

The group file is simply a convenience when it comes to name, and of course to define which users are part of which group.

Likewise, you could in /etc/passwd set user fred to have group 4000 as a number.

I'm not sure if you can have an empty group name in /etc/groups

[And as larsmans points out, NIS may also affect names of users and groups]

I hope this answers your question.

share|improve this answer
add comment
  1. It is possible that there are alternative locations for group definitions, as specified in nsswitch.conf:

    • NIS

    • LDAP

    • Berkeley DB files, instead of flat files

    • ... and any number of alternative methods that may or may not be available as additional NSS modules in a system.

  2. It is possible that a filesystem object belongs to a UID or a GID that has not been defined in /etc/passwd, /etc/groups or via any alternative name service. As far as the kernel is concerned, that is perfectly acceptable, since it's the userspace that provides the mapping to human-readable names anyway. In that case, userspace tools will typically display the numeric ID instead of a name.

    On the other hand, while entirely possible, having objects with an invalid UID or GID is usually an indication for a problem of some significance - quite often it will be a user that has been removed without proper handling for their files. Such a situation is not acceptable in most cases, because it allows for the possibility of an information leak should the UID/GID in question be reused for a new user/group who would now find themselves owning a number of files from a past user...

We might be able to help more if you mentioned your actual issue...

share|improve this answer
add comment

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.