Linux Rename File Command

I‘m a new Linux user. How do I rename a file called resumezzz.pdf to resume.pdf using Linux bash command prompt?

You need to use the mv command. It is used to rename and move files and directories.
How to Rename Files in LinuxFig.01:
To rename multiple files use rename command or script provided by MySQL/MariaDB package as per regex.

How to rename a file Linux?

The syntax is as follows:
mv old-file-name new-file-name
mv [options] old-file-name new-file-name
mv file1 file2

Examples: Renaming files with mv Command

In this example, rename a file called resumezzz.pdf to resume.pdf. Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
mv resumezzz.pdf resume.pdf
If resumezzz.pdf is located in /home/vivek/docs/files directory, type:
cd /home/vivek/docs/files
mv resumezzz.pdf resume.pdf

mv /home/vivek/docs/files/resumezzz.pdf /home/vivek/docs/files/resume.pdf
Use the ls command to view files:
ls -l file1
ls -l file1 file2
ls -l /home/vivek/docs/files/*.pdf
ls -l *.pdf

Linux rename a file syntax

In short, to rename a file:
mv file1 file2
You can get verbose output i.e. mv command can explain what is being done using the following syntax:
mv -v file1 file2
Sample outputs:

`file1' -> `file2'

To make mv interactive pass the -i option. This option will prompt before overwriting file and recommended for new users:
mv -i file1 file2
Sample outputs:

mv: overwrite `file2'? y

How to use rename command to renames multiple files

The syntax is:
rename 's/old/new/' files
rename [options] 's/old/new/' files

For example, rename all perl files (*.perl) to *.pl, enter:
rename 's/perl/pl/' *.perl
rename -v 's/perl/pl/' *.perl
Sample outputs:

'bar.perl' renamed to ''
'foo.perl' renamed to ''
'input.perl' renamed to ''
'output.perl' renamed to ''
'test.perl' renamed to ''

The above command changed all files with the extension .perl to .pl. See “Howto Rename Multiple Files At a Shell Prompt In Linux or Unix” for more info.

Detailed information about mv command

You can also view the manual page on mv using the following command:
man mv
info mv
man rename

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 15 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
15 comments… add one
  • Linux in malawi Nov 19, 2012 @ 13:44

    Thank you very much. It worked

  • Nick Feb 6, 2014 @ 15:20

    While the move command will work, there is actually a rename command:


    Which in this case would be:

    rename resumezzz resume resumezzz.pdf

  • Aaron Feb 22, 2014 @ 20:07

    For those of us arriving because we googled the syntax for the “rename” command in linux, this is annoying.

  • fawad Apr 28, 2014 @ 11:50

    thank you sir… :)

  • sri Apr 30, 2014 @ 16:32

    “ls -l ” is this commend applicable for listout all..

  • akhter Jun 4, 2014 @ 6:06

    Thanks it’s working

  • Guest Jun 4, 2014 @ 8:03

    rename texttoreplace textreplacement listoffiles

    If I want to remove some text I use just use “”

    rename texttoremove “” *

    • Mike G May 5, 2015 @ 21:03

      “rename texttoreplace textreplacement listoffiles

      If I want to remove some text I use just use “”

      rename texttoremove "" *"

      Thank you!!! First post that clearly showed what each argument represented. It was not as obvious in the “foo foo0 foo?” example in the man pages. I think it would have been better to give an example like yours, or something like “foo bar foo?”.

  • Gabe Sep 25, 2014 @ 10:33

    Just to randomly add a mv command I like and find handy…

    mv test{,.OLD}

    Can do some fun little combo’s with that.

  • Turbo Built Jan 5, 2015 @ 5:18

    Thank you for this guide. I’m a windows user and so I’m not too familiar with linux commands, but I’m using git for windows which allows for unix commands, so I wanted to learn. Thanks you.

  • ashish Mar 17, 2015 @ 10:20

    Can i move 2files together into one file ?

    • Steve Jun 22, 2015 @ 19:07

      @ashish, you can use the cat command for that:
      cat file1 file2 > file1and2

  • may Jul 11, 2016 @ 14:47

    thank you for sharing, vivek.

  • Sir Feb 12, 2017 @ 23:43

    This just deleted my file.

  • jbc Jul 17, 2017 @ 14:02


    I am trying to rename all files in a directory using mv but it isn’t working!

    My code is:
    id= ’29 10 15′
    for zzvar in ${id} ; do
    mv /media/storage/DTI/vgcross_sj${var}*


    even when I take the loop out and just try the command with one subject, I get the error: mv: target:/media/storage/DTI/vgcross_SJ is not a directory.

    Obviously it’s not a directory, because that’s what I’m trying to rename the file as!
    Do you have any ideas as to why it’s not working?

    Thank you very much!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum