Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a rather simplistic understanding of file permissions on *nix systems. I understand that there is a file owner and file group, but is there a hard and fast rule on whether the said file owner must belong to the file group also? Or put another way, can a file belong to a group that the owner is not a part of?

If so (or if not), why? I'd like to increase my understanding... I can't seem to find anything that specifically talks about this out on the interwebs... I'm also open to some good reading material on the subject.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

No, there's no need for a file's owner to belong to that file's group. There's no mechanism in place for checking or enforcing this. Additionally, a user could belong to a group at one time and then be removed; nothing will go through the filesystem to check for files that would be in conflict.

Basically, the owner and group metadata for a file is just sitting there on the disk, and doesn't have any external links. (Tangent: it's stored by numeric user id and group id, and these are resolved by the system when asked.)

Also, only one set of permissions is ever used at a time — if you are the owner, only owner permissions are looked at and the group permissions don't matter. If you are not the owner but are in the group, group permissions are used. Finally, if you are not in the group nor the owner, the "other" permissions are used. If you are both the owner of a file and in the file's group, it doesn't really matter.

share|improve this answer
    
Thanks for your answer. This confirms my hunch... I just had a sense that owner trumps group but came across this "rule-of-thumb" at work. Guess it's just one of those monkey see, monkey do thing. –  user1766760 Apr 4 '13 at 18:07
    
Are you saying that if I'm the owner of a file, and I'm in the group that "owns" it, and the group has permission to write and execute while I only have read permission, then the group permissions will be ignored for me? –  iconoclast May 14 '13 at 18:52
1  
@iconoclast That is correct. Create a file and type "Hello world" in it. It has your user and group ownership. Then, do a chmod 460 on it and try to edit it. I believe I have read it somewhere but the term used is that the user and group permissions in a Unix file are decoupled. –  unxnut Jun 21 '13 at 13:21
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.