Home » Linux » Shell » Linux Rename Directories

How to Rename a Directory in Linux

In this tutorial, we explain how to rename a directory in Linux, using the “mv” and “rename” commands.

Renaming directories is not very different from renaming files. Because after all, this is Linux, where everything is a file. Even the directories. So, most of what we discussed with renaming files works here too.

Renaming directories with mv

mv RenameDir/ renameDir
mv Command to Rename Directory
mv Command to Rename Directory

There it is. Just mv it, like the song. Only special concerns, if you have anything directed to the directory. Make sure to search your files for any mention of the name.

grep search
grep search

This way you can find any reference to the old directory name. Go ahead and search and replace to change it to match.

Rename multiple directories with rename

Same as with files, use rename.

rename - rename files

rename [options] expression replacement file...

If you want to learn more about the process, look to the renaming files article, where I go into more detail.

rename foo foo0 foo*

And that’s it, add a 0 to a directory name. Add anything, or rename anything.

rename Command to Rename Directory
rename Command to Rename Directory


Renaming directories is a simple task. It’s very similar to renaming files. The only caveat, it’s important to remember that your scripts are not targeting that directory.

Photo of author
I'm a writer, in the sense that there are words written and things needing explaining. Years of schooling, running on twelve now, taught me one thing, I like taking the complicated down to complex. So, I'm writing about Linux. One of those things that starts as complicated, and after a few years turns into complex. Until the next new thing rolls out anyways. Working in IT, I learned advocating for your product is the only way to ensure adoption. Providing user manuals, pictures, diagrams, and everything else possible to our community. That's what builds the "user-friendly" experience. Not only design, but inclusion. Talk to me about Linux, I'm here to learn by teaching.

Leave a Comment