How to use Linux common command cp

王林
Release: 2023-05-16 14:40:13
forward
1285 people have browsed it

Copy the file test.txt to the /usr/local directory

cp test.txt /usr/local
Copy after login

Copy the folder yyTest to the /usr/local directory

cp -r yyTest/ /usr/local
Copy after login

Copy the file again test.txt to the /usr/local directory, force overwrite

cp -f test.txt /usr/local
Copy after login

Copy the file test.txt to the /usr/local directory again, and ask whether to force overwrite

cp -i test.txt /usr/local
Copy after login

Copy the file tests.txt to / usr/local directory, and copy the modification time and access permissions

cp -p test.txt /usr/local
Copy after login

Linux cp introduction:

Linux cp (English spelling: copy file) command is mainly used For copying files or directories.

Syntax

cp [options] source dest
Copy after login

or

cp [options] source... directory
Copy after login

Parameter description:

-a: This option is usually used when copying a directory. It retains links and 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 an 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.

The above is the detailed content of How to use Linux common command cp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template