mv moves an item to a new place. It works the same as cp, with one difference: after mv, the source is gone.
cp a.txt b.txt
a.txt and b.txttwo files
mv a.txt b.txt
b.txtone file
Rename
A rename is a move in the same directory:
text
learner@tidepool:~/shop$ mv draft.txt menu.txt
learner@tidepool:~/shop$ ls
menu.txtMove into a directory
When the destination is a directory that exists, the item goes into it and keeps its name:
text
learner@tidepool:~/shop$ mv monday.txt tuesday.txt ordersMove and rename in one step
Give the destination a full new path:
text
learner@tidepool:~/shop$ mv draft.txt archive/menu-2025.txtDirectories
mv moves a directory as one item, with everything under it. It needs no -r.
cp | mv | |
|---|---|---|
| The source after it | Stays | Is gone |
| Directories | Need -r | Work with no flag |
| A destination file that exists | Written over | Written over |