Categories: LinuxShellUbuntu

How to Rename Files in Ubuntu 20.04

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.

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

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

Write the name of the new file and press enter.

The file will be renamed.

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.

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

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

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

$ ls

Method # 3: Renaming multiple files using rename command

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

$ sudo apt install rename -y

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.


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

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

  • ‘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

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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago