Removing large directories in Linux

Ever try to delete the contents of a large directory in nix type operating system? If you have many files you will get an error like “list to long” or something like that. This happens to some of my directories I use to cache pages, sometimes I want to clear them out manually.

List too long

So now what?

The easiest and quickest solution is to remove the entire directory with a command like this.

(Now, before you do it, you need to realize that you will have to recreate the directory when it’s done, so take note of the permissions you have on the directory first.)

rm -rf directoryname

rm -rf

You can see the directory is now gone “No such file or directory”.

Yes, that is exactly what I wanted!

This entry was posted in other stuff and tagged , , . Bookmark the permalink.

One Response to Removing large directories in Linux

  1. Mitre Box says:

    Thanks.

    Saved a couple of hours.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>