mv Linux Commands

What is Linux mv Command?



mv command which is short for move. It is used to move/rename file from one directory to another. mv command is different from cp command as it completely removes the file from the source and moves to the directory specified, where cp command just copies the content from one file to another.


mv [-f] [-i] oldname newname


-f This will not prompt before overwriting (equivalent to --reply=yes). mv-f will move the file(s) without prompting even if it is writing over an existing target.
-i Prompts before overwriting another file.


  1. To Rename / Move a file:

    This command renames file1.txt as file2.txt
  2. To move a directory
    mvhscripts tmp

    In the above line mv command moves all the files, directories and sub-directories from hscripts folder/directory to tmp directory if the tmp directory already exists. If there is no tmp directory it rename's the hscripts directory as tmp directory.
  3. To Move multiple files/More files into another directory

    This command moves the files file1.txt from the current directory and file2.txt from the tmp folder/directory to newdir.

Ask Questions

Ask Question