mv: Moving and Renaming
One command, two jobs.
Moving a file, and renaming a file, sound like two different jobs. But to Linux, they're the same thing. Both just change where a file lives, and what it's called. So one command does both. MV, short for move.

- Moving and renaming
- The same job to Linux
- mv does both
Renaming
To rename, move the file to a new name in the same folder. MV to do dot TXT, tasks dot TXT. The old name is gone, and the file now has its new name. Unlike copy, there's still only one file.
mv todo.txt tasks.txt ls Documents Downloads Music Pictures notes.txt tasks.txt
Moving into a folder
To move, give a folder as the destination. Here we move notes dot TXT into Documents. It disappears from home, and appears in Documents. Moving folders works the same way, and doesn't need dash R.
mv notes.txt Documents ls Documents Downloads Music Pictures todo.txt ls Documents cv.txt notes.txt report.txt
Careful: no undo
There's one danger with MV and CP. If the destination file already exists, it's replaced, without any warning. There's no recycle bin. Dash I, for interactive, makes them ask first. Dash N means never overwrite. When in doubt, check with LS before you move.
| key | value |
|---|---|
| Danger | replaces existing files |
| No warning | by default |
| -i | ask before replacing |
| -n | never overwrite |
Summary
MV renames when the destination is a new name, and moves when it's a folder. And watch out, it overwrites without asking, unless you use dash I. Next, deleting.
Key takeaways- mv old new: rename
- mv file folder: move
- -i asks first