I'm programming a Fuse file-system.
So far so normal, didn't encounter unsolvable problems (except performance).
However, I read the following articles:
http://linuxcommand.org/lts0070.php
http://www.perlfect.com/articles/chmod.shtml
http://mason.gmu.edu/~montecin/UNIXpermiss.htm
http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions
http://www.tutorialspoint.com/unix/unix-file-permission.htm
https://kb.iu.edu/d/abdb
And I've got the following question:
Given a generic unix-permission-string –
I understand the string (after the first char) is partitioned into
groups of 3 (rwx) for
owner
owner_group
all/world/anyone
However, one of the articles explicitly states, 1 user can be in N groups.
So why the singular here for owner group (not groups) ?
What exactly is the owner group, if I (the file creator and therefore owner) am in several groups ?
Say I'm member of group A, group B, and group C.
Now I create a file somewhere.
Since the expression owner_group is singular and not plural,
to which group get's the owner_group permissions applied ?
A XOR B XOR C, or all of them, or none of them ?
If it gets applied to only one (as the singular implies), how is determined which group the rights are assigned to ?
I have the distinct feeling I don't really understand something here, or that I misunderstand the meaning of the term "owner group".
Best Answer
foo
owns the file and one of the user's groups isfoo
), then the respective group permissions apply to that user (unless overridden by the owner permissions).The owner group is part of the file's ownership. Consider:
This states that the file's ownership is with user
root
and groupcrontab
.That depends on what your primary group is at the time you created that file. The primary group is the first one listed when you run the
groups
command. Usually, this is determined by your GID. However, you can temporarily set one of your other groups as primary using thenewgrp
command. For example:That the owner group is an attribute of the file, not the user.
Slightly off: the third field is others, not all. Others covers everyone except the owner of the file and members of the owner group of the file. The distinction comes into play when using symbolic modes with
chmod
:chmod a-x
takes away everyone's execute permissionschmod o-x
takes away everyone else's execute permission, while leaving the owner and owner group's execute permission untouched.Lastly, a note on user private groups. UPGs are fairly common on desktop systems, but do not take them for granted elsewhere. If UPGs are enabled, it is likely that the user's primary group and username have the same numeric id and name, and there is a unique group for each user. That is all.