The command CP command for the CentOS Linux system

Source: Internet
Author: User


in the in Linux systems, the command used to copy files or directories is CP, which can copy the source files to the target file or complicate multiple source files to the target directory.

command format:CP [ option ] Source Address (file or directory) destination Address (file or directory)

Command options:

-A,--archive equivalent to -dr,--preserve=all

--backup[=control] Create a backup for a target file that already exists

- b similarto-backup, but does not accept parameters

--copy-contents in recursive processing is to copy special file contents

-F,--force If the destination file cannot be opened, remove it and try again ( you do not need to select this if the-n option exists)

-I,--interactive before overwriting (invalid with the previous- n option)

-H Follow the command-line symbolic link in the source file

-L--link link file without copying

-L,--dereference always follow the symbolic link

-N,--no-clobber do not overwrite existing files (invalidates the previous- i option )

-R,-R, recursive copy all items in directory and directory

Command case:

1), copy a single file to the target directory, the file does not exist in the destination directory file

command:cphello.txt one.txt

[email protected] ~]$ CP hello.txt One.txt

[Email protected] ~]$ ls-l

Total Dosage 16

Drwxrwxr-x 2 Balich Balich 4096 8 months 07:44 doucment

-rw-rw-r--1 Balich Balich 8 months of 07:48 hao.txt ...... .....????????????.

-rw-rw-r--1 Balich Balich 8 months 07:44 hello.txt

-rw-rw-r--1 Balich Balich 8 months of 07:48 one.txt .............. target file (*). Destination Files

[Email protected] ~]$

2), the target file exists, will ask whether to overwrite

command:cphello.txt one.txt

[email protected] ~]$ CP hello.txt One.txt

CP: Do you want to overwrite "One.txt"? y ... ... ..... ... ... ... ... ... .... ..... ..... .... ..... ..... ..... ........, ... and ... and .... ...... tip whether to overwrite

[Email protected] ~]$ ls-l

Total Dosage 16

Drwxrwxr-x 2 Balich Balich 4096 8 months 07:44 doucment

-rw-rw-r--1 Balich Balich 8 months 07:48 hao.txt

-rw-rw-r--1 Balich Balich 8 months of 07:44 hello.txt ...... ....... source File

-rw-rw-r--1 Balich Balich 8 months 07:52 one.txt ... the target file, from the time can be seen has been modified

[Email protected] ~]$

3), copy the entire directory

command:cp-r document/tmp

[Email protected] ~]$ cp-r doucment//tmp

[Email protected] ~]$ ls-l/tmp/doucment/

Total Dosage 4

-rw-rw-r--1 Balich Balich 8 months 07:56 hao.txt

[Email protected] ~]$


This article is from the "Eight Miles Bridge" blog, please be sure to keep this source http://baliq.blog.51cto.com/5984262/1689930

The command CP command for the CentOS Linux system

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.