Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. 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
    
Don't cross-post –  Sathya May 26 '11 at 9:39

3 Answers 3

up vote 3 down vote accepted

Use

cp -a

(archiving) or

cp -p

(preserve mode, ownership and timestamps)

share|improve this answer
    
Isn't this exactly what is not intended? –  maxelost May 26 '11 at 16:03
    
@maxelost Only if the target file exists. There's two ways to interpret the question. Copy changes permissions to the user doing the copying, and that is likely not what is intented. –  Daniel Beck May 26 '11 at 16:23

There is a better answer at ServerFault:

cp --no-preserve=all source target
share|improve this answer

Look at the --no-preserve option

share|improve this answer

Your Answer

 
discard

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.