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