Unix Command To Rename A Folder

by on January 2, 2009 · 2 comments· LAST UPDATED November 2, 2009

in , ,

How do I rename a folder under UNIX operating systems using a command line tools?

You need to use the mv command to rename a folder under UNIX operating systems. You must have write permission for all folders.

Syntax

The syntax is as follows:

mv old-folder-name new-folder-name
mv /path/to/old /path/to/new

Example

In this example, a folder called drivers is renamed as olddrivers. Open a terminal (shell prompt) and type the following commands:

ls
mv drivers oldrivers
ls


If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+, or even by subscribing to our RSS Feed.


{ 2 comments… read them below or add one }

1 Rogelio September 25, 2011 at 11:27 pm

I how do I move a file or folder into another directory? I have tried mv file.rtf ~/Documents mv ~/file.rtf ~/Documents and mv ~/file.rtf ~/Documents/ none of these work.

Reply

2 Ikem April 4, 2012 at 5:03 pm

I would try:

mv “file.rtf” “Documents”
mv “$HOME/file.rtf” “$HOME/Documents”

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , , , , ,

Previous Faq:

Next Faq: