Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to turn off the prompt for linux to use the cp command

Shulou Source: shulou.com Published: 2022-06-03 03:33:02 09月22日 Update

By default, when cp overrides, it doesn't matter what parameter-f is added or prompts whether or not to overwrite.

The reason is: the server will add the alias alias cp='cp-iTunes by default, but when you execute cp, you actually execute cp-I.

[root@ltt01] # aliasalias 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 and overwrites it directly, eliminating the need for the user to click y to interact, which is important when the script is executed.

Here are two ways to solve this problem.

Method 1: ban aliases

[root@ltt01] # vi ~ / .bashrc

Add "#" before alias cp='cp-i' and comment out the line,: wq! Just save the exit and log in again.

Method 2: add\ before cp

[root@ltt01 ~] #\ cp 1.txt / back/1.txt [root@ltt01 ~] #

These are the details of linux without prompting when using the cp command, please pay attention to other related articles!

Tags: Tips information aliases methods commands important practices content reasons parameters that is situations articles more servers comments users scripts or questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Xiaomi MySQL Microsoft Shulou Technology