How to rename a file in Linux
A step-by-step guide on how to rename a file in Linux
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 <old name> <new name>
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 get the BEST of Tom's Guide direct to your inbox.
Here at Tom’s Guide our expert editors are committed to bringing you the best news, reviews and guides to help you stay informed and ahead of the curve!
Emma Street is a freelance content writer who contributes technology and finance articles to a range of websites, including Tom's Guide, Top10.com, and BestMoney. She has over 15 years of experience working in technical development within the fintech industry. When not writing about tech, Emma can be found writing romantic fiction, reviewing films, and updating her tea blog.