How to delete a directory in Linux command line

Evilware 5 years ago 0 770

When attempting to remove a directory in the command line on a Linux box you may receive an error “directory not empty” when trying to run

rmdir  thedirectorytodelete

The solution to this is to run

rm -rf thedirectorytodelete

This will force the directory and all the contents there in to be erased.

You will be asked if you wish to proceed


If you want to be asked for each file, then you would do

rm -r thedirectorytodelete


remember always to use caution when using  rm -rf as

rm -rf /

Would be disastrous.


Written By

Leave a Reply

Leave a Reply

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