Renaming a file is a basic operation in any operating system. Files can be renamed in multiple ways in Linux. The task can be achieved using GUI or command-line. Moreover, advanced utilities can also be used to rename these files. All these ways are documented in this article in a way that is easy to follow.

Prerequisites

  • Ubuntu 20.04 system
  • User with sudo privileges for renaming multiple files.

Note: The commands discussed in this article have been tested on Ubuntu 20.04 LTS (Focal Fossa).

Method # 1: Renaming files using GUI

We will be renaming a file named file.txt.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Right-click on the file that needs to be renamed. A menu appears on the screen.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Click on the rename. The name of the file will become editable.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Write the name of the new file and press enter.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

The file will be renamed.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Method # 2: Renaming files using mv command

mv command has the following syntax.

mv [source] [destination]

Right-click in the folder where the file to be renamed is present.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Click on open in terminal to open the directory in command line.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

We will use mv utility to move files. The file name file.txt can be renamed to document.txt using the following command:

$ mv file.txt document.txt

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

The file can be checked to have renamed. Run the following command in terminal:

$ ls

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Method # 3: Renaming multiple files using rename command

Run the following command on the terminal to install rename utility.

$ sudo apt install rename -y

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

We will be renaming multiple files in txt files to md files. The name or corresponding text file will remain name when it’s extension is moved to markdown. We have three text files as the following image suggests.

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Run the following command in terminal for renaming all these files:

$ rename ‘s/.txt$/.md/’ *.txt

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

  • ‘s/.txt$/.md/’ – Substitute .txt in place of .md.
  • *.txt – Apply the operation on name of all the files.

The files can be checked to have renamed by using the following command:

$ ls

How to Rename Files in Ubuntu 20.04 linux shell ubuntu

Conclusion

In this article, we have explored how to rename a file using GUI as well as command-line. Moreover, a utility has also been explored to rename multiple files at once. We hope you can easily rename files and folders in Linux after following this article.