Back to the command reference

mv

FilesBeginner In simulator In real Linux

Move or rename files

Name: mv = move

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

mv moves or renames files and directories. Within one file system it only changes directory entries, so it is instant regardless of size; across file systems it copies the data and then removes the original.

An existing destination is overwritten by default; -i asks first and -n never overwrites.

Syntax

mv [OPTION]... SOURCE... DEST

Common options

-i / --interactiveAsk before overwriting
-f / --forceNever ask before overwriting
-n / --no-clobberNever overwrite existing files
-u / --updateMove only when the source is newer or the destination is missing
-v / --verboseExplain what is being done
-b / --backupBack up a file before overwriting it, as name~
-t / --target-directory DIRMove everything into DIR (the destination first, handy with xargs)
-T / --no-target-directoryTreat the destination as a plain name even if it is a directory (for renaming)

Examples

  • $ mv README.md INTRO.md

    Rename a file

    Explain
  • $ mv data/fruits.txt documents/

    Move a file into another directory

    Explain

Related