0

I have 2 users, each has a different primary group. For user1, the primary group is group1 with GID 501. For user2, the primary group is group2 with GID 502.

I edited /etc/passwd manually so that user1 now has GID 600. However, I forgot to create a new group with GID 600 (and I did not edit /etc/group either).

What's surprising me is that even though I never created a group with GID 600 (and thus there's no such group in /etc/group)- everything works as if such a group exists:

Examples:

1) After user1 creates a new file- test.txt- User2 can't r/w that file.

2) When running ls -l I can see that test.txt belongs to GID 600.

What am I missing? Why does it work even though there's inconsistency between /etc/passwd and /etc/group?

Thanks.

0

What's surprising me is that even though I never created a group with GID 600 (and thus there's no such group in /etc/group)- everything works as if such a group exists

Not quite everything: a user can only belong to such a nameless group if it is their primary group, i.e. the group ID is specified on their line in /etc/passwd. But that is just a consequence of how the non-primary group membership information is stored.

The kernel fundamentally handles the users and groups by UID and GID numbers; the names are essentially just a friendly user interface layer for us humans. POSIX-compliant filesystems also tend to store file ownerships by UID/GID numbers, not by user/group names.

Sometimes it is also necessary to work with incomplete user/group information. For example, a system that is relying on a central LDAP or NIS user database must not destroy file owner/group information merely because a network failure is causing the user information database to be unreachable.

Or when you are restoring a system after a total system disk failure, it would be inconvenient to have an absolute requirement to restore the user/group information first before anything else. (Granted, it might usually be one of the first things you restore, but it is not absolutely mandatory to do so.)

0

For a file to belong to a group (the group is a numerical value), this group doesn't need to exist locally.

THe best example to show this is a USB disk written on a system where GID 600 is locally defined and then moved to a system where it does not exist locally. The files will show up all right, with the numerical value 600 not being resolved to a group name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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