🐧 Linux mv Command
Move and rename files and directories across folders and partitions.
Syntax
$ mv [options] source destination
Common Command Options
| Option | Description |
|---|---|
-i | Prompt interactively before overwriting an existing destination file |
-n | Do not overwrite an existing file (no-clobber) |
-u | Move only when source file is newer than destination or destination is missing |
-v | Verbose mode: explain what is being done step-by-step |
-f | Force: do not prompt before overwriting (default in non-interactive shells) |
-b | Make a backup of each existing destination file before overwriting |
Practical Examples
Rename a File
mv old_report.txt new_report.txt
Renames old_report.txt to new_report.txt without changing its directory.
Move File to Another Directory
mv photo.jpg /home/ubuntu/pictures/
Moves photo.jpg into the pictures folder.
Move Multiple Files at Once
mv index.html style.css?v=2.6 app.js?v=2.6 /var/www/site/
Transfers three separate files into the destination folder in one command.
Move with Wildcard Pattern
mv *.log /var/log/archive/
Moves every file ending in .log into the archive directory.
Safe Interactive Move
mv -i secret.key /keys/secret.key
Prompts for confirmation before replacing an existing file.