Linux Basic Command--CP

Source: Internet
Author: User

CP (option) (parameter) copy
When copying multiple source files, the target must be a directory.
The CP command uses the-I option by default, and when the target already has a file, asks the user if it is overwritten, and can use \CP to cancel the-i option

-A: Copies all the properties of the file, which are used to archive the file. , and then archive the compressed command
-D: When a symbolic connection is copied, the destination file or directory is also established as a symbolic connection and points to the original file or directory connected to the source file or directory;
-F: Forcibly copying a file or directory if there is a direct overwrite of the target file or directory

-I: If the destination file or destination directory exists, ask the user whether to overwrite

[Email protected] admin]# cp-i A/C b/cp:overwrite ' b/c '? Y this is also the default way of the CP command [[email protected] admin]# alias Cpalias cp= ' Cp-i '

-L: Make a hard connection to the source file, copy the Innode number of the source file instead of copying the file;

[[email protected] admin]# cp/a a[[email protected] admin]# cp-l/a aa[[email protected] admin]# ls-li/a a AA plus-i          Displays the inode number of the file 139923-rwxr-xr-x.  1 root root 0 Dec 01:45 A          This is a file that is copied directly over 12090-rwxrwxrwx. 2 root root 0 Dec 00:55/a       This is the source file 12090-rwxrwxrwx. 2 root root 0 Dec 00:55 aa      This is a file copied over by Cp-l.

-P: Preserves the properties of the source file or directory;

[[email protected] admin]# CP AA/[[email protected] admin]# ls-l aa/aa-rwxrwxrwx. 1 Admin admin 0 Dec 00:55 aa-rwxr-xr-x. 1 root  root  0 Dec 01:13/aa as the root user, when I copy the AA file under the Admin user's home directory to the root directory, the owner and host group of the file becomes root. [Email protected] admin]# cp-p aa/cp:overwrite '/aa '? Y[[email protected] admin]# ls-l aa/aa-rwxrwxrwx. 1 Admin admin 0 Dec 00:55 aa-rwxrwxrwx. 1 Admin admin 0 Dec 00:55/AA When you add the-p option, the files that have been copied are not changed by the owner or the original admin
This-p seems to be the original file belongs to the main group is the root of invalid???

-R/R: Recursive processing, copy all the files under the specified directory and subdirectories;

[[email protected] admin]# CP-RV b C ' B ', ' c/b ' b/c ', ' c/b/c ', ' b/c/d ', ' c/b/c/d ' b/c/d/e '

-S: Create a symbolic connection to the source file instead of copying the file;

[Email protected] admin]# cp-s/a aa[[email protected] admin]# ls-l aalrwxrwxrwx. 1 root root 2 Dec 01:32 AA/A

-B: The target file is backed up before overwriting the existing file target;

[Email protected] admin]# cp-bv/a acp:overwrite ' a '? Y '/A ' (Backup: ' a~ ') [[email protected] admin]# ls-l a*-rwxr-xr-x. 1 root root 0 Dec 01:42 a-rwxrwxrwx. 2 root root 0 Dec 00:55 a~

-V: Show Operation procedure

It's been shown all over the top.

Linux Basic Command--CP

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.