Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How to use cp command without to overwrite target file permissions

for example

cp /tmp/file   /home/file

I dont want to change chown and chgrp on /home/file

share|improve this question
It's not clear whether you are asking about preserving the source permissions or the target permissions. You've also cross-site spammed to SuperUser. –  Tom Shaw May 26 '11 at 9:00

3 Answers 3

up vote 16 down vote accepted

If you've only opened the manual for cp...

The next will not overwrite the file permissions and ownership + groupship:

cp --no-preserve=mode,ownership /tmp/file /home/file

Note that root privileges are needed if you want to preserve the ownership and groupship.

An excerpt from the manual:

      preserve   the   specified   attributes   (default:  mode,owner-
      ship,timestamps), if possible  additional  attributes:  context,
      links, xattr, all
share|improve this answer

cat will work, too:

cat /tmp/file > /home/file
share|improve this answer

Or you can use even better install program from GNU coreutils that has been made for this particular purpose. Please note it is not able to recurse (no -R or -r option).


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.