permissions not inheriting to subdirectories/files
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
permissions not inheriting to subdirectories/files
Hello,
How would I go about having the group permissions propagate down to the sub directories/files automatically?
Let's say you create a directory named "finance" and group named "accounting" and do:
chown root:accounting finance
chmod 770 finance
and when a user named bob creates a file inside of "finance" directory, the owner and group get set to bob:bob for that file and not bob:accounting. Is there a way to have the group permissons auto-inherit so that don't need to manually change the permissions every time for other users in the group when they need to edit the file?
Sorry, I meant the group ownership not being inherited.
It seems need to do chown manually every time when a user creates a file/directory b/c it doesn't auto-inherit from the parent directory.
Is there a way for any new directories/files created under finance directory to inherit the group ownership from the parent directory?
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660
Rep:
It's been a while since I played with Linux permissions, but off the top of my head...
umask is the bitmask on the permissions, so if the default is 777 then umask 022 would make the file 755. You don't want to set the umask to 755 or you would get a file with permissions of 022.
In order for directory contents to inherit group ownership, I think they have to be 2775, or was it 1775? I can't remember. Try 1775 first, if that doesn't work go with 2775. The first bit is for setuid/setgid/sticky. 4 is setuid, 2 is setgid, and 1 is "sticky".
Check out the man pages for the chmod command. In there you'll read about the "set user ID" and "set group ID" permissions that you can set for the directory. When these are set for a directory, all newly created files in that directory will have the same group and owner attributes.
So for the directory in question you would set the permission, using the chmod command, to "6xxx" where where xxx is for the User Group and Other permissions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.