How to Rename Files in Linux

This guide will illustrate how to retitle files in Linux.

Retitling files in Linux can be done in several ways, using either command-line tools or file managers. You will explore some of the common methods with examples here.

Let us follow the steps to rename files in Linux:

  1. Using the ‘mv’ Command: The mv (move) command is the most common way to rename a file.
    1. Syntax:
      mv old_filename new_filename
    2. Example:
      mv report.txt checked_report.txt

      This renames ‘report.txt’ to ‘checked_report.txt’ in the current directory.
      Note: If you specify a different path, the file will be moved instead of just retitled.

  2. Using the ‘rename’ Command: The rename utility is useful for retitling multiple files at once, particularly with patterns.
    1. Syntax:
      rename ‘s/old_pattern/new_pattern/’ files
    2. Example:
      rename ‘s/.txt/.bak/’ *.txt

      This retitles all ‘.txt’ files in the directory to ‘.bak’.

    3. The availability of retitle depends on your Linux distribution. Install it if needed:
      sudo apt install rename # Debian/Ubuntu
      sudo yum install rename   # CentOS/RHEL
  3. Using GUI File Manager: If you are using a desktop environment (GNOME, KDE, XFCE, etc.):
    1. Open the file manager.
    2. Right-click on the file.
    3. Choose Rename and enter the new name.
  4. Using ‘mmv’ (Multiple Move): The mmv tool lets bulk retitling of files with flexible patterns.
    1. Example
      mmv “*.jpg” “image_#1.jpg”

      This renames all ‘.jpg’ files with a prefix ‘image_’.

    2. To install mmv:
      sudo apt install mmv # Debian/Ubuntu

This way, you can retitle files in Linux and choose the method that best fits your needs, whether it’s a quick single rename or bulk changes.

Learn more tutorial: How to Edit the Hosts File in Windows, macOS, and Linux.

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

Special Features of Microsoft Hyper-V Server 2008 R2

The new stand-alone hypervisor from Microsoft designed to further the efficiency of the virtualization technology.…

How to Fix the HTTP 405 Method Not Allowed Error

The 405 is an HTTP error that occurs when the web server is configured in…

How to Incorporate Trash Folder Data into Email Disk Quota Calculations

In this article, we will explain how to incorporate trash folder data into email disk…