Commands · Command

CommandLinuxmacOS

cp

cp [options] source destination

Copies a file or directory to a new location, leaving the original in place.

// FLAGS

-rrecursive, required for directories
-ppreserve permissions and timestamps
-iprompt before overwriting
-vverbose, print each file copied

// EXAMPLE

cp -r ~/project ~/backup/project — copies the whole project directory tree into backup.

// GOTCHA

Copying a directory without -r fails with "omitting directory" — a very common first-week mistake.

// RELATED COMMANDS