Home » How to Rename a Directory Linux: A Complete Guide

How to Rename a Directory Linux: A Complete Guide

How to Rename a Directory Linux

Renaming directories in Linux can be a tricky task, especially for beginners. However, with the right commands and techniques, you can easily rename any directory folder in your Linux system. I will guide you on renaming a Linux directory with various examples and commands for different distributions.

Renaming a Single Directory

To rename a directory in Linux, you can use the mv command, which stands for “move”. This command can also be used to move files or directories from one location to another. Here is the basic syntax for renaming a single directory:

mv [old_directory_name] [new_directory_name]

For instance, to rename a directory named depth type to moving files, use the following command:

mv depth\ type/ moving\ files/

The backslash (\) is used to escape the space in the directory name.

Renaming Multiple Directories

If you want to rename multiple directories in one go, you can use the find and rename commands. The find command helps you to locate all the directories that you want to rename, and the rename command renames them according to the pattern you provide. Here is the basic syntax for renaming multiple directories:

find [directory] -name '[old_directory_name]*' -exec rename 's/[old_directory_name]/[new_directory_name]/' {} \;

For instance, to rename all directories named mv home to home directory under the /home directory, use the following command:

sudo find /home -type d -name 'mv home*' -exec rename 's/mv\ home/home\ directory/' {} \;

Note that you need to install the rename command using the following command:

sudo apt install rename

Comparing Renaming Commands

Both the mv and rename commands are commonly used for renaming directories in Linux. The mv command is easier to use for renaming a single directory, whereas the find and rename commands are better for renaming multiple directories. Additionally, the find and rename commands provide more flexibility as they allow you to rename directories based on a specific pattern or criteria.


Renaming directories in Linux is a common task that can be accomplished using various commands and techniques. Whether you are using a command line interface or a graphical user interface, knowing how to rename directories in Linux is essential. In this article, we have discussed different commands and techniques for renaming single or multiple directories. You can easily manage your files and directories in Linux by mastering these commands.

In brief, renaming a directory in Linux is straightforward, using the mv command for a single directory and the find and rename commands for multiple directories. The Linux command line interface provides powerful tools for managing files and directories, and knowing how to use them is crucial for any Linux user.

Ilyas Ozkurt

Hello I'm İlyas Özkurt. I am a software developer who has been working on websites for 10 years. My first studies in this field were during my high school years. Now I work as a software developer at 6harf and am responsible for all web projects there.

Add comment