I need to copy and over-write a large amount of files, I've used the following command:

# cp -Rf * ../

But then whenever a file with the same name exists on the destination folder I get this question:

cp: overwrite `../ibdata1'? 

The Problem is that I have about 200 files which are going to be over-written and I don't think that pressing Y then Enter 200 times is the right way to do it.

So, what is the right way to that?

2 Answers 2


You can do yes | cp -rf myxx, Or if you do it as root - your .bashrc or .profile has an alias of cp to cp -i, most modern systems do that to root profiles.

You can temporarily bypass an alias and use the non-aliased version of a command by prefixing it with \, e.g. \cp whatever

  • 4
    +1 for pointing at how to bypass an alias. Tempted to -1 for the brute force solution.
    – Hennes
    Commented Jul 24, 2014 at 21:43
  • 7
    +! for the yes pipe function - very handy! Commented Dec 16, 2016 at 8:08
  • what does -rpf do? I have seen it used multiple times in scripts.
    – tushar
    Commented Apr 21, 2020 at 21:32

You do realise that RHEL and CentOS have tried to protect novice users by setting up aliases for the root user to prevent accidentally overwriting and deleting files?

alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'

The -i switch is what requires confirmation when modifying or removing existing files. Because alias expansion happens before execution of the command even the use of the --force -f switch will still require confirmation.

You can remove the alias permanently by editing the /root/.bashrc file, remove the alias for the duration of a session with unalias cp or for a single command use one of:

  • use the full path /bin/cp
  • use quotes "cp" or 'cp' around the command
  • use the command keyword e.g. command cp
  • escape the command \cp

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .