cp is a Linux shell command to copy files and directories.
You can use the “cp” command to copy a file. For example, the following command copies the file “file.txt” to the file “copy_file.txt”:
cp file.txt copy_file.txt
You can use the “cp” command to copy a directories.
Copy from source to dest
$ cp [options] source dest
cp command main options:
| option | description |
|---|---|
| cp -a | archive files |
| cp -f | force copy by removing the destination file if needed |
| cp -i | interactive – ask before overwrite |
| cp -l | link files instead of copy |
| cp -L | follow symbolic links |
| cp -n | no file overwrite |
| cp -R | recursive copy (including hidden files) |
| cp -u | update – copy when source is newer than dest |
| cp -v | verbose – print informative messages |