cp is a Linux command that copies files and directories.

Common flags

FlagDescription
-aArchive mode — preserves permissions, timestamps, ownership, and copies directories recursively (equivalent to -dR --preserve=all)
-rRecursively copy directories
-vVerbose — print what is being copied
-iInteractive — prompt before overwriting
-uCopy only when the source is newer than the destination
-pPreserve file attributes (mode, ownership, timestamps)

Examples

cp -a /source/dir /destination/dir

Recursively copies /source/dir to /destination/dir while preserving all file attributes.

cp -iv file.txt backup/

Copies file.txt to backup/ with verbose output and a confirmation prompt before overwriting.