2

I want all directories and files to inherit same permissions as parent directory.

  • Strictly permissions, or owner/group? – Jeff Schaller Jun 4 '16 at 14:47
  • If the permission of a directory is 700,i want all files and directories created to have same permissions – Lavanya Nidhi Jun 4 '16 at 15:35
  • If permission on a directory is 700, other users/groups won't be able to enter it and access its files, no matter the files' permissions. – spectras Jun 4 '16 at 22:19
3

You can achieve that with ACLs, check this answer for an introduction: https://unix.stackexchange.com/a/12847/130303

You'll probably need default ACLs to achieve what you want to do. Lets say you have a directory test (with files and dirs already in it) and you want user and group to be able to write and others only to read, you can set default ACLs (recursively) with the first three commands and then set it for the existing files in the other three commands:

setfacl -R -m d:u::rwx test
setfacl -R -m d:g::rwx test
setfacl -R -m d:o::rx test
setfacl -R -m u::rwx test
setfacl -R -m g::rwx test
setfacl -R -m o::rx test

You can check the ACLs with the command getfacl:

$ getfacl test
# file: test
# owner: youruser
# group: yourgroup
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x
  • 1
    I agree that ACL's are the answer but what you've linked doesn't describe default ACL's which is what would give the OP what they want. Also I think answers that are just links elsewhere are generally frowned upon. Usually answers are supposed to be self-contained. If you edit your answer to include the default ACL's that the OP is looking for I'll upvote it. – Bratchley Jun 4 '16 at 16:26
  • Yeah, you are right, I was in a hurry. – Jakob Lenfers Jun 4 '16 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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