How to rename files and directories in Linux?

renaming files in linux

Renaming files and directories may feel a bit complicated because there are no pre-defined commands to do so. But you can rename a file using the “mv” command or install the rename command on your Linux system. If you are not confident enough in using the bash commands, we have also listed out GUI options to rename a file in Linux. 

Rename Files and Directories

In this tutorial, we will first learn renaming files in Linux using the bash or shell commands. To do this, we will use the “mv” command first and then use the “rename” command as an alternative. In the later section of this blog post, we will also learn the GUI options to rename a file or directory in Linux operating system. 

Renaming a file in Linux using the “mv” command – 

The “mv” command is a shorthand for the move command, which signifies moving files and directories. Using the “mv” command, you can change a single file or multiple files from a source to a destination. 

The general syntax of using the “mv” command is,

mv [options] source destination 

Using the “mv” command, you can easily rename a file by specifying the old file name and the new file name. 

Here is the example to change/rename a file name in Linux using the “mv” command – 

mv old_file_name new_file_name

Using the above command, you can change the file name “old_file_name” to “new_file_name” using the terminal. 

Another example for using the “mv” command to rename a file in Linux – 

mv oldlife.pdf newlife.pdf

To use options with the “mv” command while renaming a directory or file in Debian or Linux system, use the following – 

mv [options] oldlife.pdf newlife.pdf

To know the list of options available with the “mv” command, type –help and the list of options will be listed. 

Here is how to use the –help, 

mv –help

Note: To rename a file in Linux, you need to be in the directory you want to rename a file. 

Also read: How to delete files and directories in Linux – Simple Guide 

How to rename a file or directory in Linux using the “rename” command – 

The “rename” command is more advance than the “mv” command. This command requires you to have the basic knowledge of regular expressions; there are two versions of the “rename” command. 

If you want to rename multiple files in Linux, you can use the “rename” command, which is the best fit. 

The rename command is not pre-installed on the Linux operating system. Here are the commands to install the “rename” command on your Linux and Ubuntu operating systems. 

Install rename command on Ubuntu and Debian system – 

sudo apt install rename

To rename a file or directory using the “rename” command, we have the following syntax – 

rename [options] perlexpr files

There are multiple options available with the “rename” command; you can use the –help to list out all the options. 

You can rename multiple files using the “rename” command. To rename multiple files in Linux using the rename command, use the following general syntax – 

rename ‘s/old/new/’ files

rename [options] ‘s/old/new/’ files

Let me give you an example to rename multiple files using the rename command.

Here is the example, 

rename ‘s/pl/perl/’ *.pl

The above command renames all the files with .pl extension to .perl extension. 

Here is the complete tutorial on rename command by how to forge. In this tutorial, you get to know about all the options available with the rename command. 

But I am a bit uncomfortable with using the terminal command. Are there any GUI options to rename a file in Linux? 

Also read: How to check the version of Linux? Check Linux Version

pyRenamer – Desktop application to rename files in Linux 

Renaming files in Linux is now super-simplified with the pyRenamer application. If you don’t want to use the terminal or if you are imperfect with regular expressions to rename a file, you can use this GUI option. With the help of pyRenamer, you can rename multiple files in a batch and also rename a single file on Linux, Ubuntu, CentOs, ArchLinux, and almost all the Linux based operating systems. 

It is the best replacement for the “mv” and “rename” command. It also makes it easier to rename files rather than complicating the Linux terminal. 

Here is the syntax to download pyRenamer, 

sudo apt-get install pyrenamer

You can clone the pyRenamer form this GitHub repo link

Also read: How To Zip A Folder In Linux Operating System?

Metamorphose2 – Renaming files and directories in Linux 

Rename file in Linux most easily by using Metamorphose2, a GUI based mass file renaming software. You can do bulk renaming without using the terminal in Linux based operating system. 

You can find the Github repo for Metamorphose2 here

Though Metamorphose2 is a software to bulk renaming files in Linux, there is a strange known issue by the commits. While renaming files in bulk or a batch, it takes longer to process the request. 


These are the best ways to rename files in Linux and Linux based operating systems. Using these methods you can easily rename the files using terminal commands. If you are unsure of how to use the command terminal, you can also use the GUI based software listed above to rename files in Linux. To read more Linux blogs, you can visit our Linux dedicated blog page here.

You may also like,

Leave a Reply

Your email address will not be published. Required fields are marked *