The Linux “Move” command is effective to move files and directories inside the file system. The mv command can be also rename a file or directory as well as relocate it to a different location. As the Linux terminal has no rename command this command also acts as a important method to rename the files and directories.
Example syntax
mv [Source] [Destination]
Where source specifies the location of the file or directory you wish to move, and destination represents the place to which you wish to move the file or directory.
Special Note
In this article we have frequently used “ls” command. To know more about the this command have a look at the article below.
How to use ls command?
frequently used mv command options
- -i: The “-i” option asks the user for approval before overwriting a file that already exists.
- -f: With the “-f” option, you can compel a command to overwrite a file without asking for your approval.
- -n: In contrast to “-i”, the -n option does not ask for confirmation before overwriting a file. Instead, if the file is present, it will simply skip it and move on to the next file.
- -v: Use the “-v” option to show verbose output of what has been done.
Use of mv command
- to move or rename files or directories in the file system.
- transfer or rename a file or directory and that it might overwrite an existing file. This is when the “-i” ,”-f” and “-n” options come in handy.
- to transfer or rename numerous files and folders without overwriting any existing files, the -n option is helpful.
- using the mv command to relocate a file or directory will delete it from its original place. As a result, if you require a copy of the file or directory, use the cp command rather than mv.
To know more about the “cp” command checkout the article linked below:
How to use cp command?
I have to thank you for the efforts you have put in writing this site. I really hope to view the same high-grade content by you later on as well. In fact, your creative writing abilities has inspired me to get my very own blog now 😉