How to copy files

with Linux

We are using the cp command to (locally) copy files/directories, for remote check scp command.

cp [option] <source> <destination>

cp --help

cp --version

Available option:

-r -R --recursive Copy directory recursively.
-s --symbolic-link Create a symbolic link instead of copying the file itself. WARNING: all source file must be absolution path with a '/' at the beginning.
-t --target-directory=directory Copy all source files in the target directory.
-u --update Copy only if the source file is newer at the destination path.
-l --link create a hard link instead of copying the file itself.
-d  Copy symbolic link instead of copying the source file (pointed by the link) to the destination path.
-f --force Force to copy.

<source> design the source path for your file/directory, example: /usr/var/file-to-copy

<destination> design the name of your copy, example: /usr/var/new-file-name

WARNING: if you need to copy an entire directory don't forget -r as option.

Wrote by Raspaud Alexandre at May 12 2018, contact alexandre.raspaud@gmail.com.