Saturday, May 28, 2022
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Glossary
  • Community Forum
  • Web Hosting Directory
  • Login
  • Register
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • How-Tos
    • Network/Internet
    • Windows
    • Software
    • Hardware
    • Blockchain
    • Policy/Legislation
    • Video
No Result
View All Result
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • How-Tos
    • Network/Internet
    • Windows
    • Software
    • Hardware
    • Blockchain
    • Policy/Legislation
    • Video
No Result
View All Result
Cloud7 News
No Result
View All Result

Home > How-Tos > How to rename a file in Linux

How to rename a file in Linux

Linux provides various ways to do basic tasks such as renaming a file. You can rename files using a GUI file manager or via the command-line terminal.

Ugur Kubilay Cam by Ugur Kubilay Cam
September 4, 2021
in How-Tos, Linux
3 min read
0 0
0
How to Rename a File in Linux
0
SHARES
194
VIEWS
Share on FacebookShare on TwitterShare on EmailFollow on Google News

There are two approaches when you rename files in Linux: via the command-line interface or the command-line. The command line is also known as the terminal. Terminal is an essential tool for administrating Linux servers, which provides Linux users with some of the best productivity tools with full power.

Table of Contents

  • Rename a file in Linux terminal using “mv” command
  • Renaming multiple files
    • Rename multiple files using the “rename” tool
      • Basic usage
      • lowercase to UPPERCASE
      • Verbose mode
    • Rename multiple files using the for loop
  • Rename a file using right-click
  • Rename a file by pressing F2 key

Rename a file in Linux terminal using “mv” command

To rename a file in the Linux terminal, enter the following command at the command line.

[email protected]:~$ mv oldFileName.php newFileName.php

You can change the name of the file located in a different folder in the current folder.

[email protected]:~$ mv /path/to/file/oldFileName.php /path/to/file/newFileName.php

Note: Actually the mv command is used to move a file.


Renaming multiple files

You can use the rename tool and the for loop to rename multiple files on Linux terminal.

Rename multiple files using the “rename” tool

First, we need to install the rename tool. Most Linux distributions do not come with a rename tool. Run the following command in the terminal to install the tool:

Install rename on Ubuntu / Debian

[email protected]:~$ sudo apt install rename

Install rename on CentOS / Fedora / AlmaLinux / Rocky Linux

[email protected]:~$ sudo yum install prename

Install rename on Arch Linux

[email protected]:~$ yay perl-rename ## or yaourt -S perl-rename

Basic usage

If you want to rename txt files to HTML, you can use the command below.

[email protected]:~$ rename 's/\.html$/\.php/' *.html

lowercase to UPPERCASE

You can use the following command to convert lowercase filenames to uppercase.

[email protected]:~$ rename 'y/A-Z/a-z/' *.jpeg

Verbose mode

You can use the -n parameter to output the command you used in verbose.

[email protected]:~$ rename -n 's/\.html$/\.php/' *.html

index.php renamed as index.html
services.php renamed as services.html
about.php renamed as about.html

Rename multiple files using the for loop

For example, we want to add dates to pdf file names.

[email protected]:~$ ls
file1.pdf
file2.pdf
...
file3.pdf

The bash script below will add the date to all pdf files in the current folder.

for i in $(ls *.pdf); do
mv $i $(basename $i .pdf)_$(date +%Y%m%d).pdf 
done

After running the code, we see that the filenames have changed.

[email protected]:~$ ls
file1_20210210.pdf
file2_20210210.pdf
...
file3_20210210.pdf

Note: If you need help renaming multiple files, you can post a comment on this page.


Rename a file using right-click

If you have the GUI, right-click the file you want to rename and click “Rename”.

Rename a file usging right click in Linux


Rename a file by pressing F2 key

If you have the GUI, click once on the file you want to rename and press F2.

Rename a file by pressing F2 key in Linux

 

ShareTweetSendShare
Get free daily newsletters from Cloud7 News Get the Cloud7 Newsletter

Check your inbox or spam folder to confirm your subscription.

By subscribing, you agree to our
Copyright Policy and Privacy Policy
Previous Post

Tomorrow Water introduces Co-Flow initiative

Next Post

Datadog to present at upcoming investor conferences

Ugur Kubilay Cam

Ugur Kubilay Cam

Ugur Kubilay Cam is the content marketing specialist of Cloud7 News. In addition to being an SEO expert, Ugur Kubilay is a Python developer and cybersecurity researcher. Ugur has a Bachelor's degree and a master's degree in Data Analysis. With more than 15 years of experience, Ugur Kubilay Cam is an active Linux user and administrator.

Related News

Flatpak app of the week Identity

Flatpak app of the week: Identity

May 28, 2022 12:00 pm
Wayland 1.21 Alpha is released

Wayland 1.21 Alpha is released

May 27, 2022 4:50 pm
AlmaLinux 9 Emerald Puma is released

AlmaLinux 9 “Emerald Puma” is available for download

May 27, 2022 3:35 pm
Clonezilla live 3.0.0-26 released

Clonezilla live 3.0.0-26 released

May 26, 2022 4:59 pm
Next Post
Datadog launches cloud security platform

Datadog to present at upcoming investor conferences

Leave a Reply Cancel reply

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

I agree to the Terms & Conditions and Privacy Policy.

Editor's Choice

Interview with Igor Seletskiy on AlmaLinux

7 best hosting control panels

How to update Linux Kernel without rebooting?

7 best Linux mail servers for 2022

7 best cPanel alternatives for 2022

7 best Linux web browsers for 2022

7 best CentOS alternatives

7 best Linux server distros for 2022

How to scan your server for Log4j (Log4Shell) vulnerability

Best web hosting service providers

AlmaLinux 8.6 Stable is ready to download

Ubuntu 22.04 LTS is available for download. What is new?

Kali Linux 2022.2 is ready for download

Advertisement

Recent News

  • Weekly round-up: 23 – 27 May
  • Effective network strategies: Managing traffic spikes and improving performance
  • Flatpak app of the week: Identity
  • Weekly tips & tricks: Web hosting #4
  • [Event] Ops 101: Explore Ethical Hacking & Cybersecurity Careers

Our Latest Interview

Interview: Erez Barak, Vice President Observability of Sumo Logic
Interview

Interview: Erez Barak, Vice President Observability of Sumo Logic

by Atalay Kelestemur
November 25, 2021 3:23 am


Cloud7 News is a news source that publishes the latest news, industry news and exclusive interviews on web hosting, cloud computing, data center, cybersecurity and linux.

News Categories

  • Web Hosting
  • Cloud Computing
  • Data Center
  • Cybersecurity
  • Linux
  • Network/Internet
  • Software
  • Hardware
  • Blockchain

Our Free Modules

  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Glossary
  • Community Forum
  • Web Hosting Directory

Get the Cloud7 Newsletter

Get FREE daily newsletters from Cloud7 delivering the latest news and reviews.

  • About Us
  • Privacy & Policy
  • Copyright Policy
  • Contact

© 2022, Cloud7 News. Latest Cloud Computing, Web Hosting, Data Center Industry and Tech News

No Result
View All Result
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • How-Tos
    • Network/Internet
    • Windows
    • Software
    • Hardware
    • Blockchain
    • Policy/Legislation
    • Video
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Glossary
  • Community Forum
  • Web Hosting Directory

© 2022, Cloud7 News. Latest Cloud Computing, Web Hosting, Data Center Industry and Tech News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.