How To Rename A Directory In Linux?

Directories or folders are used to store files and directories in Linux operating systems. The directory has also been named a folder. There are different ways to change a directory or folder name in Linux.

Rename Directory with mv Command

The mv command is the most popular command to move, rename files and directories. In most cases, the mv command is used to rename a directory or a folder. The current and new directories names are provided as parameters to the mv command. The syntax of the renaming directory in Linux with mv command is like below.

mv -R OLD_NAME NEW_NAME

In the following example, we rename the directory named “db” into the new name “database”. The mv command works with an empty directory as well as a directory with some content without problem.

$ mv -R db database

Alternatively, the absolute or full path information can be provided to change the directory name.

$ mv -R db database

Rename Directory with File Manager or Nautilus GUI Tool

Most of the Linux distributions like Ubuntu, Debian, Mint, Kali, CentOS, RHEL, etc. provide GUI-based file managers by default with different desktop environments. These file managers can be used to rename directories. In the following example, we use Ubuntu File Manager in order to change the directory named “db” name to “database”. First right-click to the directory and then select “Rename…” from the context menu.

Rename Directory with File Manager or Nautilus GUI Tool

The following screen shows directory rename for the file manager where the folder name is set for the new name and click to the “Rename” button.

Leave a Comment