prompt before overrite : cp in linux


I am new to linux. I use following command but still get interactive prompts "overite ?" for each file. I want to over rite all existing files at destination dir i.e. like "yes to all" in windows.

cp -f -r [source dir] [dest dir]

any suggestions or idea? All I want to do is copy all files and sub directories from source to dest (overwrite files at dest)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You may have an alias. Try

\cp -f -r [source dir] [dest dir]

however note that with that the sourcedir would be copied inside the destdir. You should use

\cp -f -r [source dir]/* [dest dir]

Just run following command on terminal and then try copying again you issue will be resolved

unalias cp

But above change is temporary i.e. you need to run this command every time you login and if you wish to make it permanent then edit file ".bashrc"  ( Pl. note "." before bashrc this is not typing mistake) located at home dir of that user and delete line "alias cp='cp -i'" to edit .bashrc file use following command.

vi ~/.bashrc

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

After running unalias command or after editing .bashrc file  mentioned in my previous post you dont need to pass additional parameters to cp command, simply use cp command and now it will never prompts you to type yes/no before overwriting!


cp -r <source dir> <dest dir>
Is there a file "-i" in source_dir?

If so, and if you are not willing or allowed to delete it, use

cp -r -- [source dir] [dest dir]

I would not recommend getting rid of the alias from the profile/bashrc permanently. It is safety net that is needed by everyone no matter how experience one has. One day this would haunt you when you would lose something important. Temporary unaliasing by prefixing the command by \ is safer way.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.