Skip to main content

Command referencemv

mv command (Linux / bash / sh / zsh)

Linuxbashshzshfilebeginner

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 / optionMeaning
-iPrompt before overwrite.
-nNever overwrite an existing destination.
-vReport each move.
-TTreat 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.

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.