Every wonder why somehow in CentOS, you cannot overwrite files with the cp command even with the -f option? The man page clear shows the -f will force the overwriting of the files and yet it keeps on asking if you want to overwrite the file. As it turns out, the problem lies on the fact that there’s an alias defined for cp. It was added by default to prevent newbies like me to overwrite files important system files.

In my case, here are the aliases.

[kwatog@vps ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

As you see, the cp command is added with -i parameter which means you’ll need confirmations in case you’ll be overwriting files or folders. As a workaround, you can remove the alias by invoking the following commands.

unalias cp


Comments are closed.

Post Navigation