Copy overwrite protection

I recently copied an entire directory to a folder and during the cp (copy), but some of the files were changed/modified during the cp. I went to re-copy the files again and was struck with the inevitable “do you want to over write this file…?” 19,000,000 times… I did a Ctrl+C to stop the operation and went to my bestest bud in the universe when I can’t find something, Google, and came across this little tidbit of information.

There’s a reason why cp (copy) is aliased to cp -i in /root’s .bashrc and .cshrc/.tcshrc file. After all, do you really want root to be able to overwrite a file without checking? There is a way around the problem that retains the copy protections in root’s shell. Here’s how:

\cp -f <filename> <path/to/existing_file>

Backslashing the cp command temporarily disables the alias mentioned in the shells .bashrc, but does not permanently remove the protection. Enjoy!


I am a g33k, Linux blogger, developer, student and Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.