Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report