How to Move or Rename Files in Linux (mv)
mv moves a file or directory to a new location, or renames it if the destination is in the same directory.
Published September 30, 2026
mv moves files and directories or renames them (renaming is just moving to a new name). It overwrites by default unless you use -i or -n.
How it works
Within the same filesystem the move is instant because only the directory entry changes.
There is no -r needed for directories.
Try it
mv draft.txt final.txt
mv *.log /var/archive/
ls /var/archive
Practical examples
Rename
mv old.txt new.txtMove into a folder
mv report.pdf ~/Documents/Prompt before overwrite
mv -i a.txt b.txtBulk rename (bash)
for f in *.jpeg; do mv "$f" "${f%.jpeg}.jpg"; doneCommon mistakes
- Overwriting existing files silently.
- Forgetting quotes around names with spaces.
- Moving with a glob that matches nothing.
Key takeaways
- mv moves and renames.
- -i and -n protect files.
- Quote filenames.
FAQ
How do I rename many files?
Use a loop or the rename command.
Does mv keep permissions?
Yes.