How to rename a directory using Command Line Terminal


If you have a directory on your Ubuntu Linux, Unix, or macOS system and you want to rename it via the command line Terminal, you can make use of the mv - move files command.

Syntax:

mv dir-name renamed-dir

Let's take a look at a few examples:

Example 1:

Let's say you have a directory named mydir in the current directory and you want to rename it to mydir_archive.

% mv mydir mydir_archive
How to rename a directory using Command Line Terminal

Example 2:

Let's say you have a directory named mydir directory somewhere and you want to rename it to mydir_archive. In this case, you need to provide the absolute paths.

% mv /Users/c2ctech/desktop/mydir /Users/c2ctech/desktop/mydir_archive

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap