When I copy files from one directory to another, the directory permissions get reset (e.g: from 0755 to 0775), and this causes problems, forcing me to go back and manually reset directory permissions. I'm currently doing cp -r /source/directory /destination/directory

I want to copy all of the files and new directories, but not overwrite permissions of existing directories.

3 Answers 3


Add -p flag

cp -pR /source/dir /dest/dir

From man cp:

-p     same as --preserve=mode,ownership,timestamps

To preserve links you may use cp (manpage for cp ) with the -d flag, which is equivalent to --no-dereference --preserve=links.

To combine this with the -p and -R flags you can use the archive flag -a.


My ~/.bashrc has been modified to contain

alias cp='cp -i --preserve=all'

This means when I use cp, it will also prompt before overwriting (-i), and preserve all (i.e. mode, ownership, timestamps; and if possible additional attributes: context, links, xattr).

You could always change it to just mode instead of all if you like, but I do like having this alias to change the defaults of cp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.