Removing a non-empty directory in Linux

Might sound lame..But this was one of the major problem that I used to face when I started using Linux. Whenever we want to remove a directory from the directory tree, we go to the parent directory of the directory which we want to delete. But if the directory is non-empty, then despitelogging as a superuser, we cant remove the directory. And this annoys novice users.

rmdir too doesnt come for the aid

There is a quick solution to this, which novice users (atleast me at that time) never think of !!

Use :

rm -rf <directory_path>

-r : remove recursively

-f : forcibly

Creative Commons License
Removing a non-empty directory in Linux by Ashwin Tumma is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 India License.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: