cp command
LINUX-Frequently used commands
cp command Copy the file or directory |
Syntax |
cp [Option] [Copy source file name] [Copy destination file name] |
Use this command to copy a file or directory. When executing, you must specify the source file name and destination file name. |
Frequently used options |
-r Copy the entire directory -f Force to overwrite the destination file if it already exists -i If the destination file already exists, confirm whether to overwrite it. -p Copies the source file while retaining its owner, timestamp, access rights, and other information |
Example: Copy the file. |
$ cp data.dat data_new.dat ← Copy "data.dat" to "data_new.dat". |
Example: Copy the entire directory |
$ cp -r dir1 dir2 ← Execute the "cp" command with the option "-r" |