How to Rename a File in Ubuntu

The File System Modification Vector

In a graphical interface, renaming a file is as simple as clicking it twice and typing. On a headless Linux server, there is no graphical “rename” function. The Unix architecture handles renaming by actually utilizing the “move” command. You are mathematically instructing the file system to move the data from its old filename to a new filename within the exact same directory.

How to Rename a File

The Ubuntu operating system relies on the highly versatile `mv` (move) command-line utility to execute all renaming operations.

1. Open your terminal application or connect to the server via SSH.
2. Navigate to the Target: You must use the `cd` command to enter the specific directory containing the file you wish to rename. For example, if the file is in your Documents folder, type: cd ~/Documents and press Enter.
3. Verify the Target: Type `ls -l` to list the files and ensure you know the exact, case-sensitive name of the file (e.g., `Old_Report_2023.txt`).
4. Execute the Rename Protocol: The syntax requires three components: the `mv` command, the current name, and the new name. Type the command exactly like this:

mv Old_Report_2023.txt Final_Report_2024.txt

5. Crucial Warning Regarding Spaces: If your new filename contains spaces (which is highly discouraged in Linux), you must wrap the entire new name in quotation marks, otherwise the terminal will interpret it as multiple separate commands and crash. For example:

mv old_file.jpg "Summer Vacation Photo.jpg"

6. Press Enter.
7. Analyzing the Output: If the command is successful, the terminal will return a completely blank prompt. It does not output a confirmation message. To verify the change, type `ls -l` again. You will see the old filename is completely gone, replaced by the new alphanumeric string.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.