Get all your news in one place.
100’s of premium titles.
One app.
Start reading
Tom’s Guide
Tom’s Guide
Technology
Emma Street

How to rename a file in Linux

The Linux penguin on a pink background.

Knowing how to rename files in Linux is a handy skill that allows you to give your files more meaningful names or organize them better. There's no point owning one of the best computers if you don't keep it tidy.

In this article, we'll explore the simple steps and commands you can use to rename files on your Linux system. Whether you're using a Linux distribution (distro) like Ubuntu, or making changes in the Command Line, this step-by-step guide will help you make sure that all your files are named exactly as you want.

How to rename a file in Linux

The Linux distro used in steps 1 to 4 is Ubuntu. Other distros may work slightly differently.

1. Open the Files application and find a file

Open up your Files application, and go to the file that you want to rename.

2. Right-click on File and select Rename

Right-click on the file name. This will bring up a list of options. Select Rename.

3. Rename your file

A pop-up box will appear on the screen showing your existing file name in an editable text field. Edit or rewrite your file name.

4. Check the file name has been renamed correctly

The edited file name will now appear in your file list. You can rename folders using the same method.

5. Using the mv command in the Command Line Interface

If you would like to rename your files using Linux commands instead, open your command line interface and navigate to the directory containing the file that you wish to rename.

In Linux, there isn't a specific command for renaming files. It's done using the mv command, which serves the dual purpose of moving and renaming files on the Linux operating system.

The mv command structure for renaming files is 

mv

In the screenshot above, I am correcting a spelling error by changing the name of the file 'biscut teas.xlsx' to 'biscuit teas.xlsx'.

The command line I used to do this was mv 'biscut teas.xlsx' 'biscuit teas.xlsx'.

As you can see above, the file name was successfully changed.

You can rename directories using the same method.


Remember, the process may vary slightly across different Linux distributions, but the fundamental principles remain the same. Whether you opt for the graphical approach in your Files application or choose the command line with the versatile mv command, you now have the tools to confidently and efficiently rename both files and directories in your Linux system. Happy file organizing!

Why not boost your Linux knowledge even further and learn how to find a file in Linux and how to remove a directory in Linux.

Sign up to read this article
Read news from 100’s of titles, curated specifically for you.
Already a member? Sign in here
Related Stories
Top stories on inkl right now
One subscription that gives you access to news from hundreds of sites
Already a member? Sign in here
Our Picks
Fourteen days free
Download the app
One app. One membership.
100+ trusted global sources.