*Linux File and directory copy commands in ：
Each operating system consists of thousands of files , about linux such “ Everything is a document ” The operating system is no exception , Everyone should be able to use it easily windows
File search function under , But yes linux This function may not be very familiar , I want to play linux You need to hold on to this order , because linux Not like windows
That has a fixed filename suffix , And because linux The characteristics of a hundred schools of thought under the camp , One same file in different releases , It could be different , So if you can hold on cp Use of commands , You're fumbling
linux It's going to be a lot smoother , And you'll find linux The next file search function is actually very simple , And it's better than windows The search function is very powerful !
cp command ：
function ： Copy the source file or directory to the destination file or directory .
format ：cp [ option ] Source file or directory Target file or directory
explain ： If the source file is a normal file , The command copies it to the specified target file ; If it's a directory , You need to use “-r” option , You need to copy all the files and subdirectories in the directory to the target location .
-a This command is usually used when copying directories , It recursively copies all files and subdirectories under the source directory to the target directory , And keep the file links and file attributes unchanged , It is equivalent to -dpR.
-d Keep file properties on copy .
-f,--force If the current directory file cannot be opened , Delete it and try again .
-i,--interactive And -f Different , Prompt before overwriting the target file , Require user to confirm , answer y, Target file will be overwritten . This is interactive replication .
-p In addition to copying the contents of the source file , It also copies its modification time and access rights to the new file .
-R, -r Recursively copying directories , Copy all directories and subdirectories at all levels under the source file to the target location .
-l Do not copy , Instead, create a linked file to the source file , The link file name is given by the target file .
be careful ：cp Command to copy a file , The source file remains unchanged !
File mfile Copy to directory /home/mengqc lower , And renamed examl;
$cp mfile /home/mengqc/examl
Catalog /home/mengqc Copy all files and subdirectories under to /home/liuzh in
$cp -r /home/mengqc /home/liuzh
Interactive directory /home/mengqc Chinese and English m All the leaders .c File copy to /home/liuzh in ：
$cp -i /home/mengqc/m*.c /home/liuzh