Q. I'm new to Linux and I'd like to know how to delete directory? I'm using Cent OS Linux.
A. You need to use command called rmdir. It remove empty directories
rmdir command syntax
rmdir [OPTION] {directory-name}
Delete / remove directory
To delete directory called foo, enter:
rmdir foo
Remove DIRECTORY and its ancestors
For example remove directory structure sales/99/march
rmdir -p sales/99/march
Recursive delete
Remove all directories and subdirectories, use rm command with -r option:
rm -rf /home/data/2000
Please note that rmdir command works with all Linux and Unix like operating systems. For more information read rm and rmdir command man pages:
man rm
man rmdir
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
- Printable version
- Rss Feed
- Last Updated: 9-5-07

{ 5 comments… read them below or add one }
You can also use rm -rf
It,s quite helpful here,but you should be more precise.
hi
This is very useful for me
thanks
lakshmi
Thanks a lot. Thins really helped me.
Warning!
rm -rf /home/data/2000
removes all directories AND files recursively. Option -f means force i.e. to do it without prompting.