In Linux, cp is the abbreviation of "copy file". The cp command is used to copy the specified file or directory. If the target file already exists or contains a file with the same name, the original file or directory in the target file will be copied. The file will be overwritten, and the syntax is "cp source file destination directory" or "cp source file 1 source file 2 destination directory".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What is the usage of cp command under Linux
Linux cp (English full spelling: copy file) command is mainly used to copy files or directories .
Copy a source file to the target file (folder).
The command format is: cp source file target file (folder)
This is the most frequently used command, responsible for copying a source file to the target file (folder). As shown in the figure below, when copied to a folder, the file name remains unchanged; when copied to a file, the file name changes. If the target file already exists or the target folder contains a file with the same name, the target file or the file with the same name in the target folder will be overwritten after copying.
Copy multiple files to the target file (folder) at the same time.
The command format is: cp source file 1 source file 2 target folder or cp file * target folder
This command is also used frequently. The first command format can copy multiple listed files to the target folder at once, with each file directly separated by spaces; the second command format uses the wildcard *, as shown in the figure below, to copy all files starting with " .txt" are copied to the folder testDir.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is the usage of cp command under linux?. For more information, please follow other related articles on the PHP Chinese website!