The mv
command is used to move or rename files and directories in Unix-like operating systems. It is part of the GNU core utilities package and is available on most Linux distributions.
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... SOURCE DEST
-f, --force
: Do not prompt before overwriting.-i, --interactive
: Prompt before overwrite.-n, --no-clobber
: Do not overwrite an existing file.-u, --update
: Move only when the SOURCE file is newer than the destination file or when the destination file is missing.-v, --verbose
: Explain what is being done.Move a file to a different directory:
mv file.txt /path/to/destination/
Rename a file:
mv oldname.txt newname.txt
Move multiple files to a directory:
mv file1.txt file2.txt /path/to/destination/
Use interactive mode to prevent overwriting:
mv -i file.txt /path/to/destination/
Verbose output:
mv -v file.txt /path/to/destination/
-f
option as it will overwrite files without any warning.mv
command does not create a new copy of the file; it simply changes the file’s location or name.mv
will prompt for confirmation unless the -f
option is used.