What is the use of cp command in linux system
This article mainly introduces the use of cp command in linux system, which can be used for reference. Friends who need it can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
The cp command is used to copy files or directories and is one of the most commonly used commands in Linux systems.
In general, shell sets an alias, and when copying a file from the command line, it asks if the target file already exists, regardless of whether you use the-I parameter or not.
However, if you are executing cp in a shell script, you will not be asked if you want to overwrite without the-I parameter. This shows that the command line and shell scripts are executed differently.
1. Command format:
Usage:
Cp [options]... [- T] Source destination
Or: cp [options]... Source. Catalogue
Or: cp [options]... -t directory source.
2. Command function:
Copy the source file to the destination file, or copy multiple source files to the destination directory.
3. Command parameters:
-a,-- archive equals-dR-- preserve=all
-- backup [= CONTROL creates a backup for each existing target file
-b is similar to-- backup but does not accept parameters
-- copy-contents copies the contents of special files in recursive processing
-d equals-- no-dereference-- preserve=links
-f,-- force if the target file cannot be opened, remove it and try again (when-n option
Do not need to select this option if it exists)
-I,-- ask before interactive override (invalidate the previous-n option)
-H follows the command line symbolic link in the source file
-l,-- link links the file without copying it
-L,-- dereference always follows symbolic links
-n,-- no-clobber do not overwrite existing files (invalidate the previous-I option)
-P,-- no-dereference does not follow symbolic links in the source file
-p equals-- preserve= mode, ownership, timestamp
-- preserve [= attribute list keeps the specified attributes (default: mode, ownership, timestamp), if
Additional attributes may be maintained: environment, links, xattr, etc.
-R,-r,-- recursive copies the directory and all items in the directory
Thank you for reading this article carefully. I hope the editor will share the content of the cp command in the linux system to help you. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!