Home·Terminal commands

mv

Files and directories

Usage

mv [source] [dest]

Renames or moves; without -i or -n it overwrites the target silently.

Common flags

FlagMeaning
-iAsk before overwriting the target
-nNever overwrite; leave the target as it is
-fOverwrite without asking (the default)
-vPrint each move

Examples

mv notes.txt notes.md

Rename in place.

mv *.jpg photos/

Move every JPEG into photos.

mv -n a.txt backup/

Moves unless backup/a.txt already exists.

Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does mv do?

Renames or moves; without -i or -n it overwrites the target silently.

Q. How do I type it?

mv [source] [dest] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

4 are listed here; the full set is in man mv. This command sits under Files and directories.

Related commands

man page: man mv