How/Command to rename a File/Directory – Unix/Linux

Hi all, we already discussed about the move (mv) command and the different switches of mv command. Here, we can use the “mv” command to rename a file or directory under Linux.

Syntax:

mv name newname

Where;
name – is the name of File/Dir
newname – is the new name for selected File/Dir

Example:
Here, I’ve created one folder “CryBit” to illustrate the usage of “mv”.

[[email protected] ~]# mkdir CryBit
---
[[email protected] ~]# ll -d CryBit/
drwxr-xr-x. 2 root root 4096 Mar 14 21:03 CryBit/
---

Renaming CryBit directory to Test.

[[email protected] ~]# mv CryBit/ Test
---
[[email protected] ~]# ll -d CryBit/
ls: cannot access CryBit/: No such file or directory
[[email protected] ~]# ll -d Test/
drwxr-xr-x. 2 root root 4096 Mar 14 21:03 Test/
---

That’s it..!! 🙂

 

Other useful Linux commands:
groupdel, groupmems, groupmod, useradd , usermod , chgrp, chown, ls, head, tail, top, ps, find, crontab, ftp commandstar, rpm, rkhunter, Rsync, grep,  OpenVZ commands, lsof command

Post navigation

Arunlal Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com
We like to travel. Our travelogues are published at Trip Mentor

Leave a Reply

Your email address will not be published. Required fields are marked *