What is the mv Command?
If you use the mv command in your terminal and press Enter, it moves a file or directory from its original location to the specified destination. It works in two ways: move a file or directory to another location, or rename it with a new name. You can move a file within the current directory using a relative path, or use an absolute path to move it anywhere on the system.
Syntax:
mv [source] [destination]
Example 1: Rename a file
Command:
mv file1.txt file2.txt
Explanation:
- file1.txt is renamed as file2.txt.
- In the source, the file name is file1.txt.
- The mv command changes the file name to file2.txt as soon as it runs.
- Only the name is updated; the content remains the same.
Example 2: Move with relative path
Command:
mv file1.txt ./Documents/
Explanation:
- file1.txt is moved to the Documents folder.
- The source file file1.txt is in the current directory.












