Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Rename a File in Ubuntu: GUI and Terminal Methods

To rename a file in Ubuntu, open the Files app, right-click the file, choose Rename, enter the new name, and press Enter. In Terminal, use mv oldname newname; include the file’s path if it is not in the current directory.

Rename a file in the Files app

Ubuntu’s default file manager is called Files, also known as GNOME Files or Nautilus. The exact appearance can vary slightly by Ubuntu version, but the basic process is the same:

  1. Open Files from the dock or application launcher.
  2. Browse to the folder containing the file.
  3. Right-click the file and select Rename. You can also select it and press F2.
  4. Type the new name and press Enter to confirm.

Renaming changes the file’s name, not its contents. For example, changing notes.txt to meeting-notes.txt does not edit the text inside it. If Ubuntu selects only the name before the extension, type the replacement name and leave the extension intact when you want to keep the same file type.

Rename a file in Terminal

Linux does not normally use a separate rename command for a simple file move or name change. The mv command moves a file, and when the source and destination are in the same directory, that operation renames it.

mv report.txt annual-report.txt

This command works when your Terminal is already in the directory containing report.txt. To work from another location, specify paths:

mv ~/Downloads/report.txt ~/Downloads/annual-report.txt

You can use pwd to see your current directory and ls to list its files. If a filename contains spaces, surround it with quotes:

mv "project draft.txt" "project final.txt"

Alternatively, escape each space with a backslash, as in project\ draft.txt. Quoting is often easier to read. Linux filenames are case-sensitive, so Report.txt and report.txt are different names.

What happens when you use mv

A file’s name is an entry in a directory, not usually a label embedded in the file’s contents. Renaming in the same directory changes that directory entry. When source and destination are on different filesystems, mv may instead copy the data and remove the original after a successful transfer; that is a move rather than a simple rename.

The source and destination locations matter. For example, mv draft.txt ../draft.txt moves the file to the parent directory, while mv draft.txt final.txt gives it a new name in the current directory. Before running a command, check both paths: a typo can move a file somewhere unexpected.

Rename several files

For a small number of files, the Files app lets you select multiple items and use its batch-rename option, if available in your Ubuntu version. The interface can apply a common text change or a numbering pattern. Preview the proposed names before confirming, especially if the files have similar names.

For a controlled command-line change, a shell loop can be useful. For example, this changes every lowercase .jpeg extension in the current directory to .jpg:

for f in *.jpeg; do [ -e "$f" ] && mv -- "$f" "${f%.jpeg}.jpg"; done

The loop checks that a matching file exists and uses -- so a filename beginning with a hyphen is not treated as an option. Test bulk renames on a copy or a small sample first. A broad pattern can affect more files than intended, and renaming is not automatically reversible.

Extensions, hidden files, and overwriting

Ubuntu does not require a file extension to identify a file, but many applications use extensions such as .pdf or .png to recognize formats. Changing picture.png to picture.jpg does not convert the image; it only changes the name. Use an image editor or conversion tool to change the actual format.

Names beginning with a period, such as .config, are hidden in many Linux file browsers. In Files, press Ctrl+H to show or hide hidden files. Be careful when renaming configuration files: applications may rely on their exact names.

Also check whether the destination name already exists. In the graphical file manager, Ubuntu may ask how to handle a conflict. In Terminal, mv can replace an existing destination file, depending on options and system configuration. Use mv -i oldname newname to request confirmation before overwriting. If the file matters, make a backup before a large or uncertain rename.

Common problems and safe fixes

  • Permission denied: You may not own the file or have permission to change its directory entry. Check the file and folder permissions; do not use sudo automatically. Renaming system files with administrator privileges can disrupt Ubuntu or applications.
  • No such file or directory: Check spelling, capitalization, the current directory, and spaces in the filename. Use ls, or drag a file from Files into the Terminal window to insert its path.
  • Destination already exists: Choose another name or inspect the existing file first. Do not confirm an overwrite unless you are sure the old destination is no longer needed.
  • A file seems to disappear: It may have been moved to another folder or renamed with a hidden-file name. Search in Files and check the command’s source and destination paths.

Frequently Asked Questions

What is the shortcut to rename a file in Ubuntu?
In Files, select the file and press F2. Enter the new name and press Enter.

Can I rename a file without changing its extension?
Yes. Keep the existing suffix, such as .txt, when entering the new name. Some versions of the file manager select the name separately from the extension; check the full name before confirming.

How do I rename a file with spaces in Terminal?
Put the old and new names in double quotes, for example mv "my file.txt" "new file.txt". This keeps each name together as one command argument.

Does changing a file extension convert the file?
No. Renaming image.png to image.jpg changes only the filename. Use an appropriate conversion application to create a file in another format.

How do I rename a file to a name that already exists?
Choose a different destination name, or decide whether the existing file should be replaced. In Terminal, use mv -i for a confirmation prompt before an overwrite.

Rename a File in Ubuntu: GUI and Terminal Methods
Scroll to top