How can I copy files to some destination folder such that
- Access rights are derived from umask, i.e. the copied files and folders should behave with this respect as if they have been newly created. - I know that one can apply chmod recursively to a directory branch and all subbranches, but that would also affect other files, not just the copied ones.
- The owner and group are taken from the destination folder.
Note: The SGID-Bit for the destination folder is set.
You can't set owner from a destination folder. The owner is always the user who created the file (or the owner of the original file, if root performs
cp
with the-p
parameter). You can, however, set the group from the destination folder if setgid bit is set on the folder (this should happen automatically).To create copied files with the default umask, use
cp
command with the parameter--no-preserve=all
.