I am trying to change the permissions in one of my folders and all of it’s subfolders to grab the permissions of the larger folder, but I am not able to figure out how to “push” the permissions down to the sub folders. Does anyone know how to do this?
I assume you know the basics of the chown and chmod commands, absolute and symbolic mode for the chmod command, the -R switch for recursion, etc. ?
Often you don’t want the permissions on the files in a subfolder to be exactly the same as the parent, for example you’ll have the execute permission on the folder, but not all the files in the folder. So, the folder is 755 but the files within are 644.
I also assume this isn’t something you are trying to do once and just hard code the permissions you want with chmod, chown and/or setfacl?
All that being said as givens, this thread may help if you are trying to script something generic to pull some permissions from an existing file or folder to use as an example for permissions to set on other files;
It looks like find -printf could be used in a script to return permissions from an existing file or directory and then massaged and passed to chmod. ACLs probably get more complicated.
But maybe that’s way past the level of complexity you’re looking for. If it was me and I had to do what you are asking the way you stated it, I would just use dir to check the ownership and permission bits of the parent folder and then hard code chmod/chown -R commands to set ownership and permissions as appropriate to all the files and folders within, again noting that I might want to do something different for file vs folders vs symlinks. And, if necessary, I’d use getfacl/setfacl if I needed to mess with ACLs.