How to Rename Directories in Linux

Directory management is a critical skill for anyone looking to get a grip on Linux-based operating systems. There could be scenarios where you know that you have a file somewhere in your computer and you are unable to find it, or you could have some directories for a project that might need renaming later for archival.

If you were previously a Windows user, you might not even know that there are multiple methods you can employ for renaming directories in Linux. In this guide, we will take a look at these methods and how can you rename a directory or multiple directories in Linux.

I will demo these commands on Ubuntu 22.04, but they can be customized to be executed on different distributions. Let’s get started.

Method 1: Through the File Explorer

A Windows user when starting with Linux might be overwhelmed by the commands and the terminal, so we are starting with the easiest method on the list. It can help users get a better feel of the operating system and understand how can they get around.

Renaming a single directory

The file explorer in Ubuntu is loaded with features. It’s quite different from the one in Windows. With the multiple revisions over the past couple of releases, it makes regular operations very easy. In your file explorer, navigate to the directory you want to rename. Right-click on the directory and select “Rename” from the options in the menu.


Now you need to type in the name that you want your directory to be renamed to and then click on the button to apply the changes. Now you can find the directory with the updated name in your file explorer.


Renaming multiple directories

The Nautilus File Explorer is pretty capable when it comes to renaming files and directories. If you want to rename multiple directories in Linux, you will need to navigate to the location containing all of the directories you want to rename. Select all of the directories that you want to rename, and right-click on any one of them to pull up the options menu and select “Rename”.

Now you will be presented with the option to either rename the directories using a template or you could find and replace a specific phrase from the names of the directories. For this guide, we will be using the first option. Using it you can rename the directories and create a series with the names. You can then press the “+Add” button to select the number styling.


Finally, press the “Rename” in the upper right corner to apply the changes.


You are done.

Method 2: Through the “mv” utility

We can use one of the built-in commands to not only move directories from their current location to another, but you can also rename the directories. To start using the command, let’s understand the syntax first. It is like this:

$mv [original Directory] [target Directory]


So, let’s say we have a “test” directory and we want to rename it to “sample”, we can do it as follows:

$mv test sample


You will not get any output when this command completes execution. Now you can type execute “ls” to see the change having been applied.


Method 3: Through the “rename” command

Ubuntu doesn’t come with the rename utility installed out of the box. It’s a bit more complicated than the “mv” command but let’s start by installing the utility, using:

$sudo apt install rename

If you are working on Fedora or any other distribution this installation command might vary. Using the options available with the command, you can rename multiple files and directories.

Once this is installed, you can start renaming the directories. For instance, if you want to rename the directories and replace lowercase characters with uppercase characters. We have a series of sample directories:


This is how you can rename them as:

$rename ‘y/a-z/A-Z/’ *


Now utilize “ls” to see if the change has taken place.

If you want to learn more about the command run the following to get the details about it.



Method 4: Through the “find” command

In some of the scenarios, you might not know exactly where the directories are located. In such cases the “find” command comes in handy for users. So, if you want to rename directories through it, you can combine it with the “mv” command.

So, let’s say that we have a directory named “baseus” and we want to rename it to “anker”. We can do it using:

$find . -depth -type d -name baseus -execdir mv {} anker \;


If you don’t get any error from this command, it means that changing the name has been successful. You can use the first part of the command to locate this directory.

$find . -depth -type d -name "anker"


In this guide, we explored some of the top ways you can rename directories in Linux using Ubuntu 22.04.

We explored the GUI method, the “mv” utility, the “rename” utility and the “find” command. If you want to learn more, you can pull up the help for each of these utilities to learn about all the options you can use in conjunction with the command to a more effective application.

Drop a comment below if you face any errors throughout the guide, or if you have any thoughts or concerns. Cheers.

Print Friendly, PDF & Email