Two commands, one shape:
cp source destination
mv source destination
The difference is only what happens to the source. cp leaves it alone. mv does not.
cp — copy
cp report.txt report-backup.txt
Now there are two files with identical content. Silent, as usual.
You can copy into a folder instead of to a new name:
cp report.txt ~/backup/
When the destination is a folder, the copy keeps its original name and lands inside. So that command creates ~/backup/report.txt.
Note
Copying a folder needs the -r flag, for recursive — meaning “and everything inside it, all the way down”. cp -r projects backup-projects. Without -r, cp refuses and tells you why.
Quick check
You run `cp notes.txt archive/`. Where does the copy end up?
mv — move, and also rename
mv report.txt ~/backup/
Same idea, except the original is gone from where it was.
And here is the piece that surprises people: because moving a file to a new name in the same folder is indistinguishable from renaming it, mv is the rename command:
mv report.txt report-final.txt
There is no separate rename in the classic toolkit. There does not need to be.
Quick check
What does `mv draft.md final.md` do when both names are in the current folder?
The thing both of them will do to you
Neither cp nor mv asks before overwriting the destination. If backup.txt already exists and you run cp notes.txt backup.txt, the old backup.txt is simply gone.
Important
ls the destination before you copy or move onto it. That is the whole safety procedure, and it takes two seconds. There is no undo and no confirmation .
Try it
You are in work, with report.txt and draft.md. There is an empty backup folder next door.
ls— see what you have.cp report.txt ~/backup/— keep a copy safe.mv report.txt report-final.txt— rename the original.ls— the folder now showsreport-final.txt, notreport.txt.ls ~/backup— the copy is still there under its original name.
Step 5 is the point of the exercise: the copy you made before renaming is untouched by the rename. Copies are independent from the moment they exist.