Home  >  Article  >  Operation and Maintenance  >  What does cp mean in linux?

What does cp mean in linux?

青灯夜游
青灯夜游Original
2019-05-21 16:08:0620728browse

cp means copy, which is a copy command in Linux, mainly used to copy files or directories. The cp copy command is very practical in Linux. It can copy a file (directory) under a specified path to (into) another file or directory. The following article will introduce you to the cp copy command of Linux. I hope it will be helpful to you.

What does cp mean in linux?

linux cp command

The Linux cp command is mainly used to copy files or directories.

Basic syntax:

cp [options] 源文件 目标文件(夹)

Parameter [options] description:

● -a: This option is usually used when copying the directory When used, it preserves links, file attributes, and copies everything under the directory. Its effect is equal to the dpR parameter combination.

● -d: Keep the link when copying. The links mentioned here are equivalent to shortcuts in Windows systems.

● -f: Overwrite the existing target file without giving a prompt.

● -i: Contrary to the -f option, a prompt is given before overwriting the target file, asking the user to confirm whether to overwrite. The target file will be overwritten when answering "y".

● -p: In addition to copying the contents of the file, the modification time and access permissions are also copied to the new file.

● -r: If the given source file is a directory file, all subdirectories and files in the directory will be copied.

● -l: Do not copy files, just generate link files.

Example:

Use the command "cp" to copy all the files in the current directory "test/" to the new directory "newtest", enter the following Command:

cp –r test/ newtest

Note: When using the cp command to copy a folder, you must add the "-r" parameter, otherwise the "cp: omitting directory" error will occur.

The above is the detailed content of What does cp mean in linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn