Command
mvExplanation
The `mv` (move) command is used to relocate or rename files and directories. If the target location exists, it overwrites files silently unless `-i` is used. When moving across different filesystems, data is copied and the source is deleted. Use `-v` to show each move operation in progress.
Common Use Cases
- •Rename files or directories
- •Move files to organized folders
- •Archive or reorganize directories
Best Practices
- ✓Use `-i` for confirmation before overwriting
- ✓Use `mv -v` to see progress
- ✓Ensure destination directories exist before moving
Common Mistakes to Avoid
- ⚠Overwriting files without confirmation
- ⚠Forgetting destination path
- ⚠Trying to move across filesystems without permissions
Troubleshooting
Problem: Permission denied when moving files
Solution: Use `sudo mv` if elevated permissions are required.
Problem: Accidentally overwritten files
Solution: Use `-i` or `--backup` to prevent overwriting important files.
Examples
Rename a file
mv old.txt new.txtMove file to another directory
mv file.txt /tmp/