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.
Adblock detected 😱
My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via
PayPal/
Bitcoin, or become a
supporter using Patreon.
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
Posted by: Vivek Gite
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.
Hi thanks..
Thank You
thank u.I want more basic comends in unix
What are the other conditions for deleting/removing directories…….?
Thanks
learning unix begins with deleting directories.
Nice
The commands are well explained with proper example. Very helpful!!
Thanks.
Fantastic! Thank you!
Thanks !!
Thanks. It works.
if you do rm -fr cppcode, it will forcefully delete the directory(making it empty and delete).
Thanks,
KARAN
It helped me :) thanks a tone :))))))
You could also do a:
rm -rf
thaks bt i want more
Thanks it works
thanks a lot..it solved my problem in a beautiful way
rm -fr also removed forcefully.
Is there any way to delete directory recurisively,,without deleting content of each directory .