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.
What is the syntax of mv command ?
It is given below:
$ mv [option] source destination
mv command Options:
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
Consider the below example
If you have the following file in a directory,
You can list them with the ls command:
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.
[Need help in fixing Linux system issues ? We can help you. ]