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: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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