Linux Step---CP command

Source: Internet
Author: User

1 command function (brief description):

Used to copy one or more source files or directories to a specified destination file or directory. It can copy a single source file into a specific file with a specified file name or a directory that already exists. The CP command also supports copying multiple files at once, and when copying multiple files at a time, the target file parameter must be a directory that already exists, otherwise an error will occur. CP--Copy

2 Command syntax:

CP "Options" source file (directory) .... Target path #注: The content in "" is not a required option

3 command options (only common command parameters are described):

Use the help command: Man CP or CP-HELP

-A,--Archive This option is typically used when replicating a directory, preserving links, file properties, and copying everything under the directory. Its function equals the DPR parameter combination.
-D,--no-dereference,--keep the link when copying preserve=links. The link here is equivalent to a shortcut in a Windows system.
-F,--force to forcibly copy a file or directory regardless of whether the destination file or directory already exists.
-I,--Interactive, in contrast to the-f option, gives a hint before overwriting the target file, asking the user to confirm whether to overwrite it, and the target file will be overwritten when the "Y" is answered.
-P,--Preserve in addition to copying the contents of the file, it also copies the modification time and access rights to the new file, saving the properties of the source file or directory.
-R/R,--Recursive if the given source file is a directory file, all subdirectories and files under that directory will be copied.
-L,--link does not copy files, but only generates linked files.

4 Usage Examples:

  (1) Cp-r source directory (file) destination directory

# Copy the Japan directory under the current directory to the specified/home/command_test/ [[email protected] home] # cp-r japan/home/command_test/ [[email protected] home] # CD command_test/ [[email protected] command_test] # ls japan[root@localhost command_test] #

(2) Cp-f source directory (file) destination directory------------Note that the default CP command is an alias (alias cp= ' Cp-i ') and cannot be forced to overwrite, even if using the-F parameter does not force overwriting the file, you can use \CP to execute the CP command without walking alias.

#Note the following use of the CP command is that there is no parameter-p result that asks if you need to overwrite; the "." At the end of the CP command statement represents the current directory[[email protected] home]#CD japan/[[email protected] Japan]#lsboduo Canglaoshi dabao.txt emoji.txt happy.txt xiaoze[root@localhost Japan]#cd/home/command_test/[[email protected] command_test]#ls1. txt dabao.txt japan[root@localhost Command_test]#Cp/home/japan/dabao.txt.CP: whether to overwrite"./dabao.txt"? Y[root@localhost Command_test]#cp-f/home/japan/dabao.txt.CP: whether to overwrite"./dabao.txt"? Y[root@localhost Command_test]#\cp-f/home/japan/dabao.txt.[[email protected] command_test]# 

Linux Step---CP command

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.