There's inheritance, and then there's inheritance

…no, not the money kind of inheritance. I'm talking about the ownership and permissions in Linux. Linux permissions are tricky for a Windows guy like me. When I copy a file to a directory on a server I expect the file to inherit the permission of the containing folder on the server. Period. Why? Because that's what NTFS does; that's how it works! Linux it's a bit more complex. I don't understand it enough to explain it, but here are some of the links and notes on what I've learned so far. I activated ACL for the volume I was working on.

apt-get install acl

 I had to edit /etc/fstab so that the / line read something like "/dev/sda1/ ext3acl,defaults,errors=remount-ro 0 1" then reboot. This allowed me to set permissions and default permissions for each folder using ACL. Here's the command I used:

setfacl -R --set u::rwx,g::r-x,o::- /www/ setfacl -R -d --set u::rwx,g::r-x,o::- /www/ setfacl -R -m g::rwx /www/wordpress/wp-content/ setfacl -R -d -m g::rwx /www/wordpress/wp-content/

 This pretty much took care of what permissions were allowed for each new object. But I wanted my new objects to have the same group as the parent, and I wanted it's subdirectories to inherit that group:

chmod g+s /www/wordpress/ cd /www/wordpress/ find . -type d -exec chmod g+s {} \;

 That's about as good as I could make it. It's not the Windows way, but it will do. EDIT: Having thought about it some more, I'm thinking that I didn't need to activate ACL for my purposes. So I'll probably end up restoring a snapshot that I took before I started messing with ACL. Still, it was a learning experience.

Leave a Reply

Your email address will not be published.