Linux cp Command
Linux Command大全
The Linux cp (full English name: copy file) command is mainly used to copy files or directories.
Syntax
cp [options] source dest
Or
cp [options] source... directory
Parameter Description:
-
-a: This option is usually used when copying directories. It retains links, file attributes, and copies all contents under the directory. Its function is equivalent to the combination of dpR parameters.
-
-d: Keep links when copying. The links referred to here are similar to shortcuts in the Windows system.
-
-f: Overwrite existing target files without prompting.
-
-i: With-f option is the opposite, it prompts the user to confirm whether to overwrite before overwriting the target file. If the user answers "y", the target file will be overwritten.
-
-p: In addition to copying the content 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, then all subdirectories and files under the directory will be copied.
-
-l: Do not copy files, just generate link files.
Online Examples
Use the cp command to copy the current directory test/ All files under the directory newtest Enter the following command below:
$ cp --r test/ newtest
Note: When using this command to copy directories, you must use the parameter -r Or -R .
Linux Command大全