Super User is a question and answer site for computer enthusiasts and power users. 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

A piece of software software I need to install on my Ubuntu Hardy system has a Makefile which includes the command cp -n.

However, I get an error stating that -n is an invalid option.

The command will work on a Mac terminal but I need it to work on Ubuntu.

Does anyone know the equivalent command for Ubuntu?

share|improve this question

migrated from May 13 '10 at 13:20

This question came from our site for professional and enthusiast programmers.

Step up a level from the immediate question -- look harder for linux (or debian or ubuntu) installation instructions. Unless this is a very niche or internal tool, there are likely installation instructions which will work better on Ubuntu. – Doug Harris May 13 '10 at 13:50

In FreeBSD (it's like Mac OS X in many ways) the option -n means "Do not overwrite an existing file." I think that in ubuntu you can use the -u flag that means update that copy only if destination is older than the source or if destination is missing.

share|improve this answer

The -n flag means "no clobbering" (do not replace existing files when copying). You can use cp -i to have cp ask whether a file should be overwritten.

share|improve this answer

cp in GNU coreutils 7.6 certainly has the -n option. Use cp --version to verify the version of cp that is being used.

share|improve this answer

Note that if you're using cp in an automated build script, the bash rewrite would simply be:

cp -n src dest


if [ ! -e dest ]; then
    cp -f src dest
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.