Renaming directories in Linux is similar to renaming files and can be accomplished using the mv command. Here’s how to do it:
Basic Syntax
mv OLD_DIRECTORY_NAME NEW_DIRECTORY_NAME
Example of Renaming a Directory
-
Renaming a Directory:
If you want to rename a directory calledold_directorytonew_directory, you would use:mv old_directory new_directory -
Renaming a Directory in a Different Path:
If the directory is located in a different path, you can specify the full path:mv /path/to/old_directory /path/to/new_directory
Important Notes
-
If a directory with the new name already exists, it will be overwritten without warning unless you use the
-ioption to prompt before overwriting:mv -i old_directory new_directory -
Ensure you have the necessary permissions to rename the directory.
Summary
Renaming a directory in Linux is straightforward using the mv command. Just specify the current directory name and the new directory name, and the directory will be renamed.
If you have any more questions or need further assistance, feel free to ask!
