-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?

closed as off-topic by Ipor Sircer, Rui F Ribeiro, slm Aug 2 '18 at 16:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Ipor Sircer, Rui F Ribeiro, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 2 '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 2 '18 at 16:58
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.

  • 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 2 '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 2 '18 at 17:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.