Common commands for copying files and folders using CentOS

Source: Internet
Author: User
Copy the files in the specified directory to the current directory and rename [root @ rehatroot] # cp ~ /. Bashrcbashrc_bakNO2. force copy the file from the specified directory to the current directory, regardless of whether the current directory contains the file [root @ rehatroot] # cp-f ~ /. BashrcbashrcN

Common commands for copying files and folders using CentOS

Cp
NO1. copy the files in the specified directory to the current directory and rename
[Root @ rehat root] # cp ~ /. Bashrc bashrc_bak


NO2. force copy the file from the specified directory to the current directory, regardless of whether the current directory contains the file
[Root @ rehat root] # cp-f ~ /. Bashrc


NO2. copy the specified directory to the current directory
[Root @ rehat root] # cp-r/root/test.
[Root @ rehat root] # cp-r/root/test /.
The two have the same effect. when copying a directory, all the last-level directories in the source path will be copied, including the directory itself.


NO3. copy files from the specified directory to the specified directory
[Root @ rehat root] # cp ~ /. Bashrc/bak/. bashrc

If the prompt is:

Cp: omitting directory

Use:

[Root @ rehat root] # cp-r ~ /. Bashrc/bak/. bashrc

 

If the prompt is:

Cp: overwrite

A slash is used:

[Root @ rehat root] #/cp-r-f ~ /. Bashrc/bak/. bashrc


NO4. during replication, all the attributes of the source file are also copied. If no parameter is specified, the properties of the target file and the source file may be inconsistent.
[Root @ rehat root] # cp-~ /. Bashrc/bak/. bashrc


NO5. if two folders need to be synchronized, one file is changed and the other file is changed, but ensure that the files of both files are up-to-date.
[Root @ rehat root] # cp-u/src/. bashrc/bak_src/bashrc

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.