≡ Menu

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. The general syntax is as follows:

mv old-file-name  new-file-name
mv [options] old-file-name  new-file-name
mv file1 file2

In this example, the following command would 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:

mv -i file1 file2

Sample outputs:

mv: overwrite `file2'? y

Detailed information about mv command

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

man mv


info mv
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 14 comments… add one }
  • Linux in malawi November 19, 2012, 1:44 pm

    Thank you very much. It worked

  • Nick February 6, 2014, 3:20 pm

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


    Which in this case would be:

    rename resumezzz resume resumezzz.pdf

  • Aaron February 22, 2014, 8:07 pm

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

  • fawad April 28, 2014, 11:50 am

    thank you sir… :)

  • sri April 30, 2014, 4:32 pm

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

  • akhter June 4, 2014, 6:06 am

    Thanks it’s working

  • Guest June 4, 2014, 8:03 am

    rename texttoreplace textreplacement listoffiles

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

    rename texttoremove “” *

    • Mike G May 5, 2015, 9:03 pm

      “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 September 25, 2014, 10:33 am

    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 January 5, 2015, 5:18 am

    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 March 17, 2015, 10:20 am

    Can i move 2files together into one file ?

    • Steve June 22, 2015, 7:07 pm

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

  • may July 11, 2016, 2:47 pm

    thank you for sharing, vivek.

  • Sir February 12, 2017, 11:43 pm

    This just deleted my file.

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , ,