Move or rename files and directories.
medium risk
mv moves or renames files. Cross-filesystem moves copy then delete. Use -i for safety in scripts. Unlike cp, the original is always removed after a successful move.
| Flag | Meaning |
|---|---|
-i --interactive | Prompt before overwriting |
-n --no-clobber | Do not overwrite existing files |
-v --verbose | Show what is being moved |
-b --backup | Create a backup of each overwritten file |
mv config.yml config.yml.bakRename file as backup before editing · explain & risk-check →mv -v /tmp/deploy/* /var/www/html/Move all deploy files to web root verbosely · explain & risk-check →mv -i *.log /archive/logs/Move all log files to archive with overwrite confirmation · explain & risk-check →Use `mv -b` to auto-create tilde-suffixed backups (~) on overwrite — great for safe config file rotation.
Reference text is hand-written and may be incomplete — check man mv for your version. Test destructive commands on a non-production system first.