Home > Operation and Maintenance > Linux Operation and Maintenance > Linux implements no message prompt when using cp command

Linux implements no message prompt when using cp command

王林
Release: 2019-12-25 14:18:53
Original
3384 people have browsed it

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'
Copy after login

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
Copy after login

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 ~]#
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template