The mv command stands for move which allows the user to move one or more files or files at once from one place to another in the file system. It can also rename files and folders and this command works without a confirmation message.
This command is built-in on Linux distributions.
Here at LinuxAPT, we shall look into how to use the mv command in Linux.
It is given below:
$ mv [option] source destination
1. -i (interactive): show overwrite confirmation message.
Press y to yes, n to no.
2. -n (no-clobber): prevent overwriting.
With this option, mv prevent overwriting of file.
3. -b (backup): back up an existing file.
The backup file will appear with the character (~) appended.
4. –version: check your version:
$ mv --version
If you have the following file in a directory,
test1.txt
test2.txt
test3.txt
You can list them with the ls command:
$ ls
In order to rename the file test3.txt to mv.txt, apply the below command:
$ mv test3.txt mv.txt
Note: Be careful not to rename the file with an existing file because it will overwrite without notice.
This article covers how to use the mv command in Linux.
mv command Options