The mv command in Linux is primarily used for two purposes:
-
Moving Files and Directories: You can use
mvto move files or directories from one location to another. For example:mv /path/to/source/file.txt /path/to/destination/ -
Renaming Files and Directories: The
mvcommand can also rename files or directories. For example:mv old_filename.txt new_filename.txt
Additional Options
-
Overwrite Confirmation: Use the
-ioption to prompt before overwriting files:mv -i file.txt /path/to/destination/ -
Verbose Output: Use the
-voption to see what is being moved or renamed:mv -v file.txt /path/to/destination/
These functionalities make mv a versatile command for file management in Linux.
