Linux - ?mv Command in Linux

The mv command is used to move or rename files and directories in Linux. It can shift files from one location to another or simply change their names without altering their content.


Basic Syntax

mv [options] source destination

Common Uses of mv

1. Move a file to another directory

mv file.txt /home/user/Documents/

Moves file.txt into the specified directory.


2. Rename a file

mv oldname.txt newname.txt

Changes the file name.


3. Move multiple files to a directory

mv file1.txt file2.txt /home/user/Desktop/

4. Move a directory

mv folder1 /home/user/Projects/

5. Prompt before overwriting a file

mv -i file.txt backup/

Asks for confirmation before replacing an existing file.


6. Force move without confirmation

mv -f file.txt backup/

Moves the file even if overwriting is required.


7. Show progress or details while moving

mv -v file.txt folder/

Displays what is being moved.


Useful Options

Option Description
-i Prompt before overwrite
-f Force overwrite
-v Verbose (shows actions)