mv command (Linux / bash / sh / zsh)
What it does
Move or rename files and directories. When people search for the mv command linux, they usually want mv's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Move or rename files and directories.
Syntax
mv [OPTION]... SOURCE... DESTINATION
Common options
| Flag / option | Meaning |
|---|---|
| -i | Prompt before overwrite. |
| -n | Never overwrite an existing destination. |
| -v | Report each move. |
| -T | Treat the destination as a normal file. |
Practical examples
Rename file
mv draft.txt final.txt
Renames a file in place.
Move several files
mv *.log archive/
Moves matching logs into archive.
Avoid overwrite
mv -n data.csv backup/
Keeps an existing destination untouched.
Linux ↔ Windows equivalent
Closest match: Move-Item (Windows / PowerShell). Move or rename items in filesystem and other providers.
Common mistakes
- Assuming mv always prompts before replacing an existing file.
- Using an unquoted glob that matches more paths than expected.
Related commands
- cpCopy files or directory trees to another location.
- rmRemove files and directory trees permanently.
- mkdirCreate one or more directories.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
FAQ
What does mv do in Linux?
Move or rename files and directories.
How do I use mv from the terminal?
Start with `mv [OPTION]... SOURCE... DESTINATION`, then choose only the options needed for the task.
What is a practical mv example?
Try `mv draft.txt final.txt` — Renames a file in place.
Can I use mv in a shell script?
Yes. mv works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.