How to Rename a Folder in Ubuntu Using the Command Line

The mv command is a powerful tool that can be used to move or rename files and directories in Linux. In this blog post, we will show you how to use the mv command to rename a folder in Ubuntu.

Steps

  1. Open a terminal window.
  2. Navigate to the directory that contains the folder you want to rename.
  3. Type the following command:
mv old_folder_name new_folder_name

For example, to rename a folder named old_folder to new_folder, you would type the following command:

mv old_folder new_folder
  1. Press Enter.

The folder will be renamed to the new name.

Tips

  • You can use spaces in folder names, but you must enclose the name in quotes. For example, to rename a folder named My Documents to My "Important" Documents, you would type the following command:
mv "My Documents" "My \"Important\" Documents"
  • You can use the -T option with the mv command to prevent the rename from happening if the new folder name already exists. For example, to rename a folder named old_folder to new_folder only if the new folder name does not already exist, you would type the following command:
mv -T old_folder new_folder

Conclusion

Renaming a folder in Ubuntu using the command line is a simple process. By following the steps in this blog post, you can easily rename any folder on your system.