The mv command can be used both to rename, and to move files and directories in Linux from a console.
Note. If you struggle to remember how the command is used, then you should check out project humanize to get a dialogue based interface.
Here is an example of how to use the mv command:
mv [file_or_directory] [new_location]
To rename a file or directory, simply write a different destination name:
mv ~/Documents/my-document-txt ~/Documents/new-name.txt
If you do not type a destination file name, the file or directory will just be moved to the new location. I.e.:
mv ~/personal-files/ ~/Documents/
This will move the personal-files directory to the Documents folder.
The mv command works both with absolute and relative paths.
MV and Special Variables
The magic variable $HOME can be used to refer to the current users home directory
The tilde (~) character has special meaning in the shell, and can be used to refer to other users home directories, as well as the current user.
# Current user (self) ~/Documents # Linking to Other users home ~Other_User/Documents