What has priority - owner/user vs group permission?
The file permissions specifically do not allow read, write or execute of that file to the owner (user1
).
If you were to change the owner to another user, then you would be able to read the file under the group permissions.
Excert from File system permissions wiki page
Classes
...
The effective permissions are determined based on the user's class. For example, the user who is the owner of the file will have the permissions given to the owner class regardless of the permissions assigned to the group class or others class.
Related videos on Youtube
humanityANDpeace
Lucky those who have knowledge to help and assist others :)
Updated on September 18, 2022Comments
-
humanityANDpeace over 1 year
I have just run into the case in which the owner-group of a file has more permissions than the owner-user of a file.
user1@pc:/tmp$ ls testfile -l ----rw---- 1 user1 user1 9 Okt 16 13:16 testfile
Since the user
user1
has no permissions to to read the file I get thisuser1@pc:/tmp$ cat testfile cat: testfile: Permission denied
This suprised me as
user1
is member of the groupuser1
which has permission to read the file.Interesstingly when doing this:
root@pc:/tmp$ addgroup user2 user1 Adding user `test' to group `ress' ... Adding user test to group ress Done. root@pc:/tmp$ su user2 user2@pc:/tmp$ cat testfile content of testfile user2@pc:/tmp$
I can read
testfile
's content.It seesms the permissions granded (or not) on the user-owner level take precedence over anything later like the permissions existing due to group membership.
My question is if there is a reference to this behaviour I experience in my linux system (that is that not having user-permissions takes away group-permissions)
Also is there a use case for this behaviour?