What does cp do?

copy files or directories.

▸ Explain your own cp command →

cp examples, explained

$ cp -r src dest

  • cpcopy files or directories
  • -rcopy directories recursively
  • srcan argument passed to the command
  • destan argument passed to the command

$ cp -p a.txt b.txt

  • cpcopy files or directories
  • -ppreserve mode, ownership and timestamps
  • a.txtan argument passed to the command
  • b.txtan argument passed to the command

cp flags & options

-rcopy directories recursively
-Rcopy directories recursively
-fforce — overwrite the destination if needed
-iprompt before overwriting
-ppreserve mode, ownership and timestamps
-vverbose — print each file as it is copied
-aarchive — recursive plus preserve everything
-ucopy only when the source is newer than the destination

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.