How do I rename a file in UNIX?
The mv is a Unix command that renames one or more files or directories. The original filename or directory name is no longer accessible. Write permission is required on all directories and files being modified.
mv Syntax
You need to use the mv command to rename a file as follows:
mv old-file-name new-file-name
Examples
Open the terminal (bash shell prompt) and type the following command to list file names:
ls ls -l
In this example, rename a file called data.txt to letters.txt, enter:
mv data.txt letters.txt ls -l letters.txt
File is renamed so the following command will display an error on screen:
ls -l data.txt
Outputs:
ls: cannot access data.txt: No such file or directory
Suggested Readings:
Type the following command to read mv command man page:
man mv
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 11/2/09



{ 0 comments… add one now }