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?
3 Answers
It is possible that there are alternative locations for group definitions, as specified in
nsswitch.conf
: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...
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.
Group memberships might be defined in NIS instead of /etc/group
. Consult your /etc/nsswitch.conf
.