My default umask is 077
. When I create a directory, it has permissions 700
:
mkdir AA
$ stat -c'%A %n' AA/
drwx------ AA/
now I want to set default permissions recursively to 750:
setfacl -R --default --modify g::rx,o::--- AA
and confirm it works as expected:
$ touch AA/zz
$ stat -c'%A %n' AA/zz
-rw-r----- AA/zz
Now I want to copy another existing directory ZZ
inside my new AA
:
$ stat -c'%A %n' ZZ ZZ/zz
drwx------ ZZ
-rw------- ZZ/zz
that existing directory has permissions 700
and file inside has 600
.
$ cp -r --no-preserve=all ZZ/ AA/
$ stat -c'%A %n' AA/ZZ AA/ZZ/zz
drwx------ AA/ZZ
-rw------- AA/ZZ/zz
but my umask is not honored, even though I have used --no-preserve=all
to specifically not transfer existing permissions from the existing ZZ
.
How can I make cp
act the same as if when I use touch
to create new files?
Regardless what the original permissions are, I want to copy over an existing directory structure, while honoring my default umask/setfacl settings.
cat < ZZ/zz > AA/zz
?rm -r AA/ZZ
, thenumask 000
and trycp …
anew. It seemscp --no-preserve=all
honors umask, whiletouch
honors the ACL.