mv Command: Tutorial & Examples
Move or rename files and directories
mv command is a utility in Linux that allows you to move or rename files and directories.
Here is the basic syntax for using
mv [options] source destination
source argument is the name of the file or directory that you want to move, and the
destination argument is the new location or name for the file or directory.
Here are some common options for
-f: Forces the move and overwrites any existing files at the destination.
-i: Prompts the user before overwriting any existing files at the destination.
-v: Verbosely displays the names of the files that are being moved.
Here is an example of using
mv to move a file named
file.txt from the current directory to the
mv file.txt /tmp
To rename a file or directory, you can use
mv and specify the same directory for both the source and destination, like this:
mv file.txt newname.txt
This command will rename the file
newname.txt in the current directory.
It's worth noting that the
mv command cannot move a file or directory across file systems. To move a file or directory to a different file system, you will need to use
cp command to copy the file or directory to the new file system, and then use the
rm command to delete the original file or