How to copy files and give them permission of destination directory

Nasreddin picture Nasreddin · Dec 17, 2015 · Viewed 26.4k times · Source

I am copying files from source to location. The source is not owned by me and the permission for files at source is ----rwx---. The permission of files coped to destination directory which is owned by me is ----r-x---. The permission of destination directory is drwxrwsrwx. How do I have the files with same permission of destination directory. I tried "cp --no-preserve=all" but it did not work (still the same permission).

Answer

Giordano picture Giordano · Dec 17, 2015

Try this:

cp --no-preserve=mode,ownership $backupfile $destination