How to remove non empty directory?

Reading Time: < 1 minute

if you trying to delete a directory and all files under it, rmdir will fail with error message:

rmdir: failed to remove '<directory>': Directory not empty

The option is t remove using rm command with -rf option. r is for recursive and f is to force and ignore warnings and errors. There is no undo option, so be very careful.

rm -rf dirToDelete

using the rm -ir generates a message for each file or directory and deletion happens based on y or n that we can type in.

Leave a comment