How do I set permissions recursively on a dir (with ACL enabled)?
setfacl
has a recursive option (-R
) just like chmod
:
-R, --recursive Apply operations to all files and directories recursively. This option cannot be mixed with `--restore'.
it also allows for the use of the capital-x X
permission, which means:
execute only if the file is a directory or already has execute permission for some user (X)
so doing the following should work:
setfacl -R -m u:colleague:rwX .
(all quotes are from man setfacl
for acl-2.2.52 as shipped with Debian)
As mentioned by umläute, the command setfacl -R
with uppercase "X" is the way to go, like:
setfacl -R -m u:colleague:rwX .
However, for those who need to re-apply ACL recrusively (i.e like "re-apply permissions on sub-directories" à la Windows).
find . -mindepth 1 | xargs -n 50 setfacl -b --set-file=<(getfacl . | sed -e 's/x$/X/')
That command could be splited to avoid error like setfacl: foobar: Only directories can have default ACLs
.
find . -mindepth 1 -type d| xargs -n 50 setfacl -b --set-file=<(getfacl . | sed -e 's/x$/X/')
find . -mindepth 1 -type f| xargs -n 50 setfacl -b --set-file=<(getfacl . | grep -v '^default:' | sed -e 's/x$/X/')
Note that the syntax <( something )
is Process Substitution, which is specific to bash. You may need to create a temporary file if you use another shell.