I want all directories and files to inherit same permissions as parent directory.
- Strictly permissions, or owner/group?Jeff Schaller– Jeff Schaller ♦2016-06-04 14:47:51 +00:00Commented Jun 4, 2016 at 14:47
- If the permission of a directory is 700,i want all files and directories created to have same permissionsLavanya Nidhi– Lavanya Nidhi2016-06-04 15:35:00 +00:00Commented Jun 4, 2016 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– spectras2016-06-04 22:19:19 +00:00Commented Jun 4, 2016 at 22:19
1 Answer
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 - 1I 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– Bratchley2016-06-04 16:26:50 +00:00Commented Jun 4, 2016 at 16:26
- Yeah, you are right, I was in a hurry.Jakob Lenfers– Jakob Lenfers2016-06-04 18:56:22 +00:00Commented Jun 4, 2016 at 18:56
- as simple as is this is the almost best answer. If you replace x with X it's the best becasue files won't get the execute permission that maybe is a most common requirement.DrLightman– DrLightman2021-01-13 17:43:17 +00:00Commented Jan 13, 2021 at 17:43