Glossary

cp

cp copies files. Given a source and a destination it writes a duplicate; given multiple sources it requires the destination to be a directory.

cp file1.txt file2.txt           # copy, overwriting file2 if present
cp file.txt backup/              # copy into directory
cp -r src/ dest/                 # recurse into directories
cp -i file.txt dest/             # prompt before overwriting
cp -p file.txt dest/             # preserve permissions and timestamps
cp -a src/ dest/                 # archive: recurse + preserve everything
cp -u src dest                   # update: only if source is newer

By default cp follows symbolic links and copies the target, not the link. Use -P to copy links themselves. For copying across machines, reach for scp or rsync.

Related terms: mv, rm, rsync, scp

Discussed in:

This site is currently in Beta. Contact: Chris Paton

Textbook of AI · Textbook of Usability · Textbook of Digital Health

Auckland Maths and Science Tutoring

AI tools used: Claude (research, coding, text), ChatGPT (diagrams, images), Grammarly (editing).