How to rename a directory?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 17 2025
0167

To rename a directory in Linux, you can use the mv command. The syntax is similar to moving a file or directory. Here’s how to do it:

Syntax

mv old_directory_name new_directory_name

Example

For example, to rename a directory called old_folder to new_folder, you would use:

mv old_folder new_folder

Important Notes

  • Ensure that you are in the correct parent directory of the directory you want to rename, or provide the full path to the directories.
  • If the new directory name already exists, the mv command will overwrite it without warning unless you use the -i option for interactive mode.

Example with Full Path

If you are not in the parent directory, you can specify the full path:

mv /path/to/old_folder /path/to/new_folder

This will rename old_folder to new_folder at the specified path.

0 Comments

no data
Be the first to share your comment!