Rename a file in the Linux terminal | Opensource.com

Rename a file in the Linux terminal

To rename a file in the terminal, move the file with mv from itself to itself with a new name. Here's an example.

rename files
Image credits : 

CC BY-SA Seth Kenlon

x

Subscribe now

Get the highlights in your inbox every week.

To rename a file on a computer with a graphical interface, you open a window, find the file you want to rename, click on its name (or right-click and select the option to rename), and then enter a new name.

To rename a file in the terminal, you actually move the file with mv, but you move the file from itself to itself with a new name.

This example renames example.txt to file.txt:

$ mv example.txt file.txt

Because they both use the same command, you can combine rename with a move. For instance, when moving example.txt to Documents, you could also rename it:

$ mv example.txt ~/Documents/file.txt

 

Move around your computer

Learn to navigate from directory to directory in the Linux terminal.
Files in a folder

Whether you're new to moving files in Linux or experienced, you'll learn something in this in-depth writeup.

About the author

Seth Kenlon
Seth Kenlon - Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time. He is one of the maintainers of the Slackware-based multimedia production project Slackermedia.