Home>Article>Operation and Maintenance> Common Linux commands: cp command example exercises
This article brings you relevant knowledge about Linux. It mainly talks about the cp command in Linux. Friends who are interested can take a look at it. I hope it will be helpful to everyone.
#Linux commonly used commands, type one article every day, three times each time, cycle once a month, all can be remembered! !
start!
Copy the file test.txt to the /usr/local directory
cp test.txt /usr/local
Copy the folder yyTest to the /usr/local directory
cp -r yyTest/ /usr/local
Copy the file test.txt to the /usr/local directory again, and force the overwrite
cp -f test.txt /usr/local
Copy the file test.txt to the /usr/local directory again, and ask whether to force the overwrite
cp -i test.txt /usr/local
Copy the file tests.txt to the /usr/local directory, and copy the modification time and access permissions too
cp -p test.txt /usr/local
Linux cp introduction:
Linux cp (English spelling: 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 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.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of Common Linux commands: cp command example exercises. For more information, please follow other related articles on the PHP Chinese website!