cp

Copy a file or a folder

What it does

cp copies a file: what first, then where. If the second argument is an existing folder, the copy goes into it under the same name; otherwise you get a file with the new name.

Folders are copied only with -r, recursively with everything inside. Without it cp refuses and says it is a directory.

Careful. If a file with that name exists, cp silently overwrites it. -i asks before overwriting.

Syntax

cp <file> <destination>
cp -r <folder> <destination>

Examples

Related commands

Practise · All commands