UNIX Delete / Remove Directory Command

by Vivek Gite on April 4, 2007 · 8 comments

How do I delete / remove a directory under UNIX operating systems?

You need to use rmdir command to remove a directory. It will remove the directory entry specified by each dirname operand, which must refer to an empty directory.

For example, to remove a directory called "cppcode", enter:
rmdir cppcode

Note:
A directory must be empty before it can be removed. Use rm command to remove all files from a directory:
cd cppcode
rm *.cpp
cd ..
rmdir cppcode

You can also recursively remove directories and subdirectories. The directory will be emptied of files and removed using rm command:
rm -r oldletters

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 8 comments… read them below or add one }

1 kjgkd October 19, 2009

Hi thanks..

Reply

2 neha April 6, 2010

Thank You

Reply

3 ashok kumar June 1, 2010

thank u.I want more basic comends in unix

Reply

4 Sumit Jain December 16, 2010

What are the other conditions for deleting/removing directories…….?

Reply

5 sathya January 28, 2011

Thanks

Reply

6 chester July 5, 2011

learning unix begins with deleting directories.

Reply

7 Helloindia September 6, 2011

Thanks.

Reply

8 Buki September 14, 2011

Fantastic! Thank you!

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 3 + 11 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: