Skip to main content

mv (Move)

Explanation

The mv command is used to move files and directories from one location to another. It is also the standard command for renaming files and directories in Linux.

Basic Syntax

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

Common Flags and Options

FlagDescription
-i, --interactivePrompt before overwrite.
-f, --forceDo not prompt before overwriting.
-v, --verboseExplain what is being done.
-n, --no-clobberDo not overwrite an existing file.

Real-world Examples

  1. Rename a file:

    mv oldname.txt newname.txt
  2. Move a file into a directory:

    mv file.txt /path/to/directory/
  3. Move multiple files to a directory:

    mv file1.txt file2.txt /path/to/directory/