Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello Everyone, I try to delete a directory by using the rm ./directory, but i am facing an error rmdir: failed to remove `directory': Directory not empty, I do not know why this happen, can anyone please help, how can i delete the directory.
try to understand. You can only remove empty directories by that command, so first you need to remove everything from that dir.
Or you may try to force remove, but that can be dangerous (rm -rf <dir>)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by lokeshjoshi
Hello Everyone, I try to delete a directory by using the rm ./directory, but i am facing an error rmdir: failed to remove `directory': Directory not empty, I do not know why this happen, can anyone please help, how can i delete the directory.
You may think the './directory' is empty but there must be hidden files or hidden directories lurking in there. Try:
Code:
$ find ./directory -ls
to see what's in there that's preventing it from being removable.
Clean those up and you should be able to remove './directory'. Note, though, that the correct command to remove the directory is
Code:
$ rmdir ./directory
If the 'find' command reveals that there are files under './directory' that you no longer need, you could issue
Code:
$ rm -frv ./directory
Warning: the above command recursively walks though './directory' and clobbers everything it finds providing that you own it. Obviously, you would want to be extremely careful using 'rm -frv' if you're logged in as root (where ownership doesn't matter), using it via 'sudo', etc.
I'd suggest reading the manpages for 'rm' and 'rmdir' and making sure the difference between is crystal clear.
First, have a look (for 'hidden' .files) with the -a ls switch
IF you choose the 'dangerous' rm -r
I strongly suggest you include the -i switch!!!
Welcome to beginning Linux @LQ!!!
You might want to look in z-lib.org or your local library or store or search the internet for beginning Linux tutorials. Also, some LQ'ers have good links in their .sig
Hi thank you for the reply, I also searched this on the internet and found this post, and also the solution provided by the members helps me a lot. to delete the directory I follow this rm -rf directory_name/, this really help me.
Hi thank you for the reply, I also searched this on the internet and found this post, and also the solution provided by the members helps me a lot. to delete the directory I follow this rm -rf directory_name/, this really help me.
in that case you might want to mark the thread as solved, also if you wish to say thanks just click on yes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.