If centos uses the CP command, the system does not prompt overwriting.

Source: Internet
Author: User

Today, I copied a folder on my VPS, but there is a folder with the same name and there are files in it. If I copied it directly, there are N prompts to confirm the replacement, press CTRL + C and search for it on the Internet. Several solutions are available:

Generally, the command we use is cp-rf sourcefile targetdir or cp-r-f sourcefile targetdir,

   -R indicates recursive replication, that is, copying a folder and all its files.

   -F indicates that a file with the same name is encountered and directly overwritten without prompting

   But why are we still prompted to overwrite the two parameters?

   This is because the system uses aliases during installation to prevent improper operations and overwrite files that should not be overwritten. Use the alias command to view the specific configuration.

[Test @ Server home] # 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'

   We can see from the above that the cp command we entered is actually the "cp-I" command,

   That is, no matter how we input cp-rf, we actually execute cp-I-rf, And it's no wonder we always ask whether to overwrite it.

   We can see from the above commands that several other commands also use aliases, such as ll, ls mv, and rm.

   How can this problem be solved?

[Test @ Server home] # vi ~ /. Bashrc
#. Bashrc

# User specific aliases and functions

Alias rm = 'rm-I'
Alias cp = 'cp-I'
Alias mv = 'mv-I'

# Source global definitions
If [-f/etc/bashrc]; then
       ./Etc/bashrc
Fi
   You only need to add the # sign before the corresponding command to comment out the command. Save and exit, and then you can use pure original commands.

 

   In fact, there is a simpler way to solve this problem, that is, add a backslash such as \ cp-f file dir before cp!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.