Linux command: CP

Source: Internet
Author: User

Full Name:Copy files and directories

Purpose: copy files (directory)

Format:

CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE ... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE ...

type:CP IS/BIN/CP

Description

Copying files (directories) inevitably involves the attributes and permissions of the file (directory) itself. Depending on the copy purpose, you may need to retain the properties and permissions of the source file (directory) after copying, or you may need to change the source file (directory) properties and permissions. Therefore, depending on the purpose, different parameters need to be used in conjunction with each other:

-A,--archive: equivalent to using "-dr--preserve=all".

--attributes-only: No file data is copied, only its properties are copied.

--backup[=control]: Create backup for existing files, backup suffix default "~" Unless "--suffix" or Simple_backup_suffix is set (see Man CP for details).

-B: Same as "--backup", just do not receive parameters.

--copy-contents: When recursion is encountered, copy the class capacity of the special file.

-D: Equivalent to "--no-dereference--preserve=links"

-F,--force: The copy is forced to overwrite if the destination file (directory) exists.

-I,--interactive: prompt when overwriting file (output y confirms overwrite, other input does not overwrite).

-h:follow command-line Symbolic links in SOURCE

-L,--link: Creates a hard link to the file, replacing the copy.

-L,--dereference: If it is a linked file, after the copy, the linked file no longer points to the source file, instead of directly using the source file content instead of the linked file content, as a normal file.

-N,--no-clobber: does not overwrite files that already exist.

-P,--no-dereference: The link file, the direct copy, and the "-l" parameter, will not replace the contents of the linked file, after the copy or link file.

-P: Equivalent to "--preserve=mode,ownership,timestamps", preserving the original properties and permissions of the file.

-R,-R,--recursive: if it is a copy of the directory, you need to recursively copy all the contents of the directory.

-S,--symbolic-link: In the current working directory, create a soft link for the source file that needs to be copied, instead of the true copy operation.

-S,--suffix=suffix: Specifies the suffix of the backup file.

-T,--target-directory=directory: Copy all files to the specified directory (add and don't, not much).

-T,--no-target-directory: Copy of the dest can not be a directory, can only be a normal file, that is, the source cannot be copied into a directory, you can copy the source to another file.

-U,--update: The source file is copied only if it is newer than the target file or if the destination file does not exist.

-V,--verbose: Displays information during execution.

-X,--one-file-system: The file system before and after the copy needs to be the same, otherwise it is not copied.

Examples of Use:

# parameter-A-p retains the source file properties and permissions, the copy file is identical, backup is very useful CP -a source DESTcp -P source DEST

Linux 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.