A method of enforcing override using CP command in Linux

Source: Internet
Author: User

When the CP is copied, if it encounters a file with the same file name, it will ask whether or not to overwrite and let you enter Yes or No. Why? This is for Linux. For security reasons, aliases are used on the CP command. That is, you enter only the CP command, in fact, you enter the system is "cp-i." The i is the interactive meaning, constantly asking you whether to overwrite. Therefore, the CP mandatory coverage has the following three methods.

Method One:

Enter the alias command to see that the CP alias is used inside the system.

The code is as follows:

#alias

< p> alias cp= ' Cp-i '

Enter the Unalias CP command to remove the alias.

The code is as follows:

#unaslias CP

(This is only a temporary cancellation of the CP alias, not permanent)

The code is as follows:

#cp a test/a

Oh, this is normal.

Method Two:

Enter the CP command, which also cancels the CP alias.

The code is as follows:

#cp a Testa

Oh, so the use is as well.

This method is equivalent to using the absolute path of the executable file directly with the CP command

The code is as follows:

#/bin/cp A.txt

Method Three:

Enter YES|CP a testa and use the pipe to enter yes automatically.

The code is as follows:

#yes | CP a Testa

See, automatically make a pile of yes, for you to enter.

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.