Ubuntu copy a file or directory command

This command is a file or directory is copied to another will give a file or directory.

 

Syntax: cp [options] source file or directory target file or directory

 

Description: This command copies the specified source file to the target file or multiple source files are copied to the target directory.

 

The options of this command is as follows:

 

- a This option is typically used when a copy of the directory. It retains links, file attributes, and recursively copy directory, which is equal to the combined effect dpR options.

 

- Keep a copy of the link when d.

 

- f deletion target file already exists without prompting.

 

- Instead i and f option to overwrite the destination file before the user is prompted for confirmation. The target file will be overwritten when you answer y, it is an interactive copy.

 

- p cp except this time copy the contents of the source file, it will also modify time and access rights are also copied to the new file.

 

- r If the source file is given a directory file, then cp recursively copy all files and subdirectories under the directory. At this time, the target file must be a directory name.

 

- l do not make copies, only links to files.

 

  Incidentally, in order to prevent other users from damaging cp command files in the case of inadvertently, such as the user specifies a target file name already exists, cp file copy command, the source file will be overwritten with new files, therefore, is recommended when using the cp command to copy files, it is best to use i option.

 

For example: Copy / home / wally / test in test.c files to / local / arm, the command:

 

cd /wally/test

 

ls

 

sudo cp -i test.c /local/arm

Guess you like

Origin www.cnblogs.com/zhengyiqun1992/p/11183783.html