The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
 


The cp command in Linux is used to copy files and directories from one location to another. It's a fundamental command for managing files and directories on the Linux command line. The basic syntax of the cp command is
cp [OPTIONS] SOURCE DESTINATION:


Here,"OPTIONS" are optional flags that modify the behavior of the cp command, "SOURCE" is the file or directory you want to copy, and "DESTINATION" is the location where you want to copy the source to.

Some common options for the cp command include:

Here are a couple of examples of using the cp command:
$ cp file.txt /path/to/destination/ ←Copying a file
$ cp -r directory_name /path/to/destination/ ←Copying a directory and its contents
$ cp -i file.txt /path/to/destination/ ←Copying a file with confirmation before overwriting
$ cp -p file.txt /path/to/destination/ ←Copying and preserving file attributes

For more examples of using cp, refer to the provided link