Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi how do I copy a folder from source to destination in Ubuntu without replacing the existing contents in the destination folder?

I tried cp -r -u and cp -r -n, and neither one worked.

share|improve this question
up vote 3 down vote accepted

I believe that if you're copying a directory using -r, the -n will only take effect against the directory being copied, not individual files, leaving you with -i which is interactive though, which means you have to stick around to watch it go. Not useful if you're scripting I suppose.

What can work instead if you're copying a source which has multiple directories within, is rsync with the --ignore-existing flag. rsync can also work for local transfer, in fact, I prefer it for copying entire directory/subdir's..

share|improve this answer

It is cp -i for interactive queries before overwriting. You can find more with man cp.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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