February 5, 2011

Supress cp "Do you want to overwrite" prompt in Fedora

When you try to copy one file over existing one as root user in Fedora you will be asked to confirm that action, but as regular user you can overwrite existing files without any question. So you can easily overwrite your own personal files, GNOME settings, documents, images, etc.

It is obvious that this is policy is made from sysadmin point of view. Sysadmins usually doesn't care if people mess up or delete their own files, as long as they don't mess up or damage system in some way.
If you look in .bashrc file of your root account you will find alias for rm, cp and mv commands:

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

I would argue that these aliases should be enabled also for regular users to keep them from messing up their files.
If you are a power user and you need to copy over whole directories over existing files you probably don't want to keep hitting that "y" button over and over.
Only way I found out that you can suppress being asked annoying "overwrite y/n" question is by deleting alias cp='cp -i' definition from root user's .bashrc file.
But maybe it is better to have protective policy enabled and just temporariliy disable it by using unalias cp command.
If you know other way to disable being asked confirming question for overwriting existing file please explain how in comments.