- 1Linux Topics Index
- 2How to Create a File in Linux
- 3How to Rename a File in Linux
- 4How to Copy a File in Linux
- 5How to Move a File in Linux
- 6How to Delete a File in Linux
- 7How to Create a Directory in Linux
- 8How to Delete a Directory in Linux
- 9How to Copy Directories Recursively in Linux
- 10Delete Directories Recursively in Linux
- 11How to View Hidden Files in Linux
- 12How to Create a Hidden File in Linux
- 13How to Create a Hidden Directory in Linux
- 14How to Find Files in Linux Using find Command
- 15Find Files in Linux Using locate Command
- 16How to View File Contents Using cat in Linux
- 17How to View File Contents Using less in Linux
- 18View File Contents Using the more Command in Linux
- 19Compare Files Using diff Command in Linux
- 20Compare Files in Linux Using cmp Command
- 21Check File Type in Linux with file Command
- 22Create Symbolic Links with ln -s in Linux
- 23How to Archive Files Using tar Command in Linux
- 24Compress Files with gzip in Linux – Beginner Tutorial
- 25How to Compress Files Using bzip2 in Linux
- 26Compress Files in Linux Using zip Command
- 27Extract Compressed Files using tar in Linux
- 28Extract ZIP Files on Linux with unzip
- 29How to Extract .gz Files using gunzip in Linux

- 1Linux Topics Index
- 2How to Create a File in Linux
- 3How to Rename a File in Linux
- 4How to Copy a File in Linux
- 5How to Move a File in Linux
- 6How to Delete a File in Linux
- 7How to Create a Directory in Linux
- 8How to Delete a Directory in Linux
- 9How to Copy Directories Recursively in Linux
- 10Delete Directories Recursively in Linux
- 11How to View Hidden Files in Linux
- 12How to Create a Hidden File in Linux
- 13How to Create a Hidden Directory in Linux
- 14How to Find Files in Linux Using find Command
- 15Find Files in Linux Using locate Command
- 16How to View File Contents Using cat in Linux
- 17How to View File Contents Using less in Linux
- 18View File Contents Using the more Command in Linux
- 19Compare Files Using diff Command in Linux
- 20Compare Files in Linux Using cmp Command
- 21Check File Type in Linux with file Command
- 22Create Symbolic Links with ln -s in Linux
- 23How to Archive Files Using tar Command in Linux
- 24Compress Files with gzip in Linux – Beginner Tutorial
- 25How to Compress Files Using bzip2 in Linux
- 26Compress Files in Linux Using zip Command
- 27Extract Compressed Files using tar in Linux
- 28Extract ZIP Files on Linux with unzip
- 29How to Extract .gz Files using gunzip in Linux

- 1How to Add a New User in Linux
- 2Modify Existing User in Linux
- 3Delete a User in Linux — Step-by-Step for Beginners
- 4Create a User Group in Linux - Step-by-Step Tutorial
- 5Linux: Add User to Group
- 6How to Remove a User from a Group in Linux
- 7Delete a User Group in Linux - Beginner Friendly Tutorial
- 8Linux su Command Tutorial – Switch Users Easily
- 9Linux sudo Command - Execute as Another User
- 10Change a User's Password in Linux Using passwd
- 11Set Password Expiry in Linux using chage
- 12Lock a User Account in Linux
- 13How to Unlock a User Account in Linux
- 14Configure User Login Shell in Linux
- 15How to Configure User Environment Variables in Linux
- 16Edit .bashrc and .profile in Linux - User Startup Files Tutorial
How to Rename a File in Linux
How to Rename a File in Linux
In this Linux tutorial, you'll learn how to rename a file using the terminal.
Alright, let’s get started!
The Command You Need: mv
In Linux, there's no separate rename
command for everyday use. Instead, we use the mv
command — short for "move" — to rename files. It's like telling Linux: “Hey, move this file from its old name to a new name... in the same place.”
Basic Syntax
mv old_filename new_filename
Let’s see it in action.
Step-by-Step Example
Suppose we have a file called notes.txt
and we want to rename it to project_notes.txt
.
ls
notes.txt
mv notes.txt project_notes.txt
ls
project_notes.txt
Awesome! You've just renamed a file.
Renaming Inside a Directory
If the file is inside another folder, like documents/
, you can still rename it using the path:
mv documents/oldname.txt documents/newname.txt
This keeps the file in the same folder but changes its name.
What If the File Doesn’t Exist?
If you try to rename a file that doesn't exist, you'll get an error like this:
mv hello.txt goodbye.txt
mv: cannot stat 'hello.txt': No such file or directory
So always make sure the file you're trying to rename actually exists. Use ls
to list files in the current directory if you're unsure.
Pro Tip: No Confirmation by Default
Linux won’t ask for confirmation if new_filename
already exists — it will simply overwrite it. To avoid that, use the -i
(interactive) option:
mv -i file1.txt file2.txt
mv: overwrite 'file2.txt'?
This gives you the chance to stop the action if needed.
Summary
- Use
mv old_name new_name
to rename files - You can rename files in any directory by including the path
- Use
-i
to prevent accidental overwrites
That’s it! You’ve now learned how to rename a file in Linux like a pro. Keep experimenting and try renaming a few files in your system.