-2

There was an answer to "Execute vs Read bit. How do directory permissions in Linux work?" regarding setting a directory permission to 5 (-R-X) value. It was said it "5: Allow reading / writing, but not altering the structure of the directory tree itself."

If I set my newly created test folder to 0570 I get the following:

dr-x-rwx---. user user test1
[user@server1 test1] touch file1
touch: cannot touch 'file1': Permission denied

Now the 'user' account is in the 'user' group so I figured if I have rwx perms as user group I could write files still. Is that not the case?

steve
  • 21,892
  • 1
    Note the . at the end of your permissions string indicates that there are additional SELinux permission restrictions applied. Try ls -lZ to dump full permissions. – user4556274 Aug 02 '18 at 16:14
  • 1
    I fail to see the "request for learning materials" here. How the user and group permissions interact seems like a valid question to me. (I wouldn't be surprised if there's a duplicate, but surely it can't be off-topic.) – ilkkachu Aug 02 '18 at 16:58

1 Answers1

2

Permissions are evaluated in order by (1) user, (2) group, and (3) other, and only the first match applies. In this case, the 'user' test matches – you are the owner of the directory. The permissions on the directory do not allow the user to write to it.

Andy Dalton
  • 13,993
  • Thanks Andy, it looks like that if you are a member of a group that has rwx perms and not the owner of the dir then you will be able to write files to that dir. – Dave Haines Aug 02 '18 at 16:25
  • 1
    Yes, that's correct. In that case, the 'user' test does not match, but the 'group' test does, and the permission on the directory allow members of the group to write to it. – Andy Dalton Aug 02 '18 at 17:15