Scenario: with a script run by a normal user I want to copy several files, and replicate the dir structure. For example:
cp --parents /lib/libacl.so /tmp/my_root/ cp --parents /lib/libc.so.6 /tmp/my_root/
Expected result: first
cp, creates /tmp/my_root/lib and puts libacl.so in there. Second
cp puts libc.so.6 in /tmp/my_root/lib.
The problem is that the first
cp creates /tmp/my_root/lib with the following permissions:
dr-xr-xr-x., so the second
cp fails with Permission denied.
Of course, if I run the script as root everything works fine.
One solution could be create the dir first and then copy the file, so the dir will have the proper permissions, but I was wondering if there was a better way of doing this, maybe some flag of
cp? I checked the man but didn't find anything.