•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

rename a file in linux

  • Home
  • Client
  • Qa Forum
  • rename a file in linux

Posted By: Jeremy | 1 Replies | Last Reply On: May 23, 2017 06:22:54

how to rename a file in linux? 

Psychz - Raviteja

Votes: 0Posted On: May 23, 2017 06:22:54
 

A file in linux can be renamed by using multiple methods. Here are some of the important methods used to rename a file in linux.

 

The "mv" (move) command

The "mv" command in linux can be used to move as well as rename a file in linux. Suppose you want to rename a file you just have to move the file to the same directory using a different name. Let us demonstrate this with an example.

Imagine you have a file named "file1" in the directory "document". You want to rename this file as "file2". Run the following command in your terminal.

 

mv file1 file2

 

 The syntax of "mv" command is :

mv "old file name" "new file name"

 

 

Some options that can be used with the "mv" command are :

1. Verbose (-v)

 

mv -v "old file name" "new file name"

This is the verbose option that will display what task the command has performed.  

Sample output - 

 

2. Interactive (-i)

 

mv -i "old file name" "new file name"

This option will prompt you before making any changes.

 

The "rename" Command

The "rename" command can be used to rename multiple files. 

Its syntax is given as : 

 

rename 's/old_name/new_name' files
rename -[options] 's/old_name/new_name' files

 

Suppose you want to change all ".jpg" files to ".jpeg" files you simply run the following command.

 

rename 's/jpg/jpeg/' *.jpg

 

These were two basic commands used to rename a file in linux. These commands come with a variety of options. Once you get the basic understanding you can move on to complex options.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Was this reply helpful?

Related topics

  • SSH File Transfer
  • How to find a file using find and locate command on Linux?
  • How to search in Linux?
  • Linux Find Commands
  • Linux Command for Find Directory
  • Basic and useful Linux commands
  • Linux File Permissions Cheat Sheet
  • How to setup a dedicated server for Minecraft
  • Set Device Name for your Devices
  • How to free up disk space on a cPanel server
  • cVirtual Connect from Windows
  • Top Useful Features Of Linux Mint
  • Scientific Linux and its features
  • What Scientific Linux is and its features
  • Top Myths About Linux Security
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801