Home  >  Article  >  Operation and Maintenance  >  How to copy files in linux

How to copy files in linux

王林
王林Original
2019-12-06 11:15:168737browse

How to copy files in linux

File copy commandcp

Command format:

cp [-adfilprsu] 源文件(source) 目标文件(destination)
cp [option] source1 source2 source3 ...  directory

Free learning video tutorial sharing: linux video tutorial

Parameter description:

-a: It means archive, which also means copying all directories.

-d: If the source file is a connection file (link file), the connection file attributes are copied instead of the file itself

-f: force (force), if there are duplicates or other questions, the user will not be asked and the copy will be forced

-i: If the destination file (destination) already exists, it will first ask whether to really operate when overwriting.

-l: Create a hard link connection file instead of copying the file itself

-p: Copy with the file's attributes instead of using the default attributes

-r: Recursive copy, used for directory copy operations

-s: Copy into a symbolic link file (symbolic link), that is, the "shortcut" file

-u: If the target file is older than the source file, update the target file

For example:

will be in the /test1 directory Copy file1 to the /test3 directory, and change the file name to file2. You can enter the following command:

cp /test1/file1 /test3/file2

More related article tutorials to share: linux tutorial

The above is the detailed content of How to copy files 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