How to Rename a Directory in Linux?

How to Rename a Directory in Linux?

3 mins read220 Views Comment
Updated on Aug 3, 2023 15:57 IST

When it comes to Linux, a lot of users visualise that it is tough to use the Linux system. Indeed, Linux systems might not be comfortable for a regular windows user. But the fact that Linux systems are very stable and less prone to viruses due to less percent share in the market makes it exciting to try.

2023_03_Difference-between-Money-Market-and-Capital-Market-4.jpg

This article will teach you how to rename a directory in Linux.

Table of Contents

Introduction

Linux and Windows systems are two of the known operating systems. The most important power that Linux users own is the use of a terminal. If you have to use Linux, you have to be comfortable with the commands that Linux offers. Although Linux is quite different from what it was a decade ago, but you still have to use the terminal quite often to install your favourite software. Or you could rename a folder (directory) by using the command line instead of the graphical user interface that Linux offers.

Explore operating system courses

This is what we focus on in the blog, how to rename a directory in Linux. In case you are a beginner, we will show you both ways of renaming directories in a Linux system, i.e., the GUI way and the terminal way. So, without any further ado, let’s head to the core of this article.

Explore free Linux courses

How to rename a directory in Linux? GUI way

If you are a beginner user of the Linux system, look around for an easier way to rename a directory in Linux. Linux offers you an entire graphical user interface (GUI) experience to perform all your tasks in case you are not a terminal or command line person. To rename a directory in Linux using GUI, follow the below steps.

Note: The below steps are performed on the Lubuntu flavor of Linux. You can learn more about Linux in detail if you are completely new to Linux systems. However, most tasks remain the same on the wide variety of Linux flavors.

Step 1: Open the files manager on your Linux system.

directory in Linux

Step 2: Once you are in the terminal. Write the command is to list all the directories and files.

directory in Linux

Step 3: Type the new name for your directory. Here we have renamed the Downloads folder to New name.

renaming a directory

Step 4: Congratulations! You have successfully renamed a directory in your Linux system.

renaming a directory in Linux

The above are the steps to rename a directory using the Graphical user interface in Linux. But what if you want to perform the same activity using the Linux terminal?

How to rename a directory in Linux? The terminal way

To rename a directory using a terminal in Linux, you have to type a bit of command since this time. We are not using GUI.

Step 1: Press ctrl + alt + t to open the terminal.

How to Rename a directory in Linux image 1

Step 2: Once you are in the terminal. Write the command ls to list all the directories and files.

Image 2

Note: If you want to rename something inside the Downloads folder, you have to use the cd command in this way: cd/Downloads, and you will be in the Downloads folder. Here you can again write the ls command and hit enter to see all the files and folders in the Downloads folder.

Step 3: We want to rename the Downloads folder. For that, we will use the command rename in this syntax:

rename ‘s/Downlaods/New_name/’ *

Image 3

Note: You might get an error if you have not installed the rename command on your Linux system. In this case, you have to write this command:

sudo apt install rename

Enter your password after the command, and it will install rename command on your system. Now you can again repeat Step 3.

Step 4: Congratulations! You have successfully renamed a directory using the Linux command line. If you again press the ls command, you will see the new name for your directory. We have used New_name for our Downloads folder so that it will show us in a below way:

rename a directory in Linux step 4

What is next?

It was a powerful way to perform an activity using the terminal. Isn’t it? You can further explore basic command lines on a Linux system to implement new things further. Linux is an open-source system, and we must embrace the capabilities of open-source community.

Contributed by: Mohit Singh

About the Author

This is a collection of insightful articles from domain experts in the fields of Cloud Computing, DevOps, AWS, Data Science, Machine Learning, AI, and Natural Language Processing. The range of topics caters to upski... Read Full Bio