This question already has an answer here:
As I understand it, a file has 3 sets of permissions: owner permissions, group permissions, and everybody else permissions. Moreover, the file has is assigned to a owner, and a group.
How linux combines all this information, to actually determine the permissions a given user has over the file?
For example, say a file is:
--- rw- --x
That is, the owner has no permissions, the group can read/write, and everybody else can only execute.
Now user "Joe" comes to this file. Depending on which groups Joe belongs to, and whether Joe is or not the owner of this file, what can he do with it? He could execute the file, because
x is set for everybody. But if "Joe" is the owner,
x is forbidden for the owner. What takes precedence?