Home >Operation and Maintenance >Linux Operation and Maintenance >Linux implements no message prompt when using cp command
By default, when cp overwrites, no matter what parameters -f or the like are added, it will still prompt whether to overwrite.
The reason is: the server will add aliases by default alias cp=’cp -i’
. When you execute cp, cp –i is actually executed.
[root@ltt01 ~]# alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
cp cancels the prompt information and directly overwrites it. The user does not need to hit y to interact, which is very important when the script is executed.
Free learning video tutorial recommendation: linux video tutorial
The following are two ways to solve this problem.
Method 1: Disable aliases
[root@ltt01 ~]# vi ~/.bashrc
Add "#" before alias cp='cp -i'
to comment out this OK, :wq! Save and exit, then log in again.
Method 2: Add \ before cp
[root@ltt01 ~]# \cp 1.txt /back/1.txt [root@ltt01 ~]#
Recommended related articles and tutorials: linux tutorial
The above is the detailed content of Linux implements no message prompt when using cp command. For more information, please follow other related articles on the PHP Chinese website!