cp

Copy files or directories from source to destination.

medium risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

cp copies files and directories. Without -r it refuses to copy directories. -p preserves timestamps and permissions — critical for backups. -u only copies when source is newer. The -i flag adds interactive prompts before overwriting.

Common flags
FlagMeaning
-r --recursiveCopy directories and all their contents recursively
-p --preservePreserve timestamps, permissions, and ownership
-i --interactivePrompt before overwriting existing files
-u --updateCopy only when source is newer than destination
-v --verbosePrint each file as it is copied
-a --archiveSame as -dR --preserve=all — full archive copy
Examples
cp -rp /etc/nginx /etc/nginx.bakBackup nginx config recursively with preserved permissions · explain & risk-check →
cp -i config.yml /etc/app/Copy config with confirmation prompt if destination exists · explain & risk-check →
cp -av /src/* /dst/Archive-copy all files verbosely showing each transfer · explain & risk-check →
Pro tip

Prefer `rsync -a` over `cp -r` for large directories — rsync is resumable, shows progress, and handles edge cases better.

Related
mv rsync tar scp
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man cp for your version. Test destructive commands on a non-production system first.