Managing files and directories is foundational for Linux workflows, and the mv (“move”) command makes it easy to relocate or rename items without hassle. Whether organizing a project, cleaning up folders, or updating your directory structures, mv is the tool to streamline these tasks.
mv [options] source destinationChange the name of a file while leaving it in the current directory:
mv daily_report.txt summary_2025.txtThis command changes daily_report.txt to summary_2025.txt. If summary_2025.txt already exists, its contents get replaced, unless you use protections.
Relocate a file anywhere within the filesystem:
mv finance.xlsx ~/work/quarterly/This sends finance.xlsx to the quarterly subfolder inside your work directory.
Transfer several files to a shared folder in one step:
mv photo1.jpg photo2.jpg photo3.jpg ~/images/events/All the listed images move to events inside images.
Update a folder’s name to reflect a new purpose:
mv draft_docs final_docsNow all contents under draft_docs appear in final_docs.
Move an entire folder including everything inside it to a different place:
mv scripts/ ~/bin/This sends the scripts directory and its files to your private bin folder.
| Option | What it Does |
|---|---|
| -i | Interactive. Ask before replacing an existing destination file or folder. |
| -f | Force. Overwrite any existing destination file without prompting. |
| -n | No clobber. Prevent overwriting existing files or directories at the target location. |
| -b | Backup. When overwriting, create a backup of the original with a tilde suffix. |
| -u | Update. Move the source only if it’s newer than the destination or if the destination is missing. |
| -v | Verbose. Show all files and folders as they’re being moved or renamed, with action details. |
| –help | Print help message about command usage and exit. |
| –version | Show the current version of the mv tool and exit. |
-i to require confirmation.-n when you want to ensure nothing gets overwritten accidentally.mv will overwrite without warning if you don’t use protections.If you’re trying to move or rename files in a protected system folder (such as /usr/local), prepend sudo to your command:
sudo mv setup.conf /etc/appsettings/Authenticate as needed to complete sensitive moves.
To move all PDFs in your current directory into an archive:
mv *.pdf ~/archive/From relocating reports and images to saving time in directory renames, the mv command is a daily driver for Linux users. Learn its flexible options to boost data safety, speed up file management, and maintain tidy, organized folders—no matter the size or complexity of your projects.
Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…
Introduction A self-signed SSL certificate is a certificate that is created and signed by the…
Introduction Debugging is an important part of Bash scripting. When a script does not work…
Introduction Cron jobs are used in Linux to run commands or Bash scripts automatically at…
Introduction Pipes are an important feature in Linux and Bash scripting. A pipe allows you…
Introduction The grep, awk, and sed commands are powerful text-processing tools in Linux. They are…