cp

The command that copies files, and with -R whole directory trees.

It replaces an existing destination file without asking unless -i or -n is given.

In more detail

Sources come first and the destination last; if the last argument is an existing directory, the copies go inside it. cp silently overwrites an existing destination unless you add -i to be asked or -n to never overwrite. -p keeps the original times and permission modes.

Examples

cp report.txt notes.txt archive/
cp -R project/ project-backup/
cp -r cookbook cookbook-copy (the copy includes .git, so it has the whole history)

Related terms

Taught in

References

Certification courses