How to Remove non-Empty Directory (rmdir – directory not empty)

Symptom

You want to delete a folder which is no longer usable. The folder is not empty and contains files / folder in the sub-directories. You have executed rm command, but the folder is not getting deleted.

# rmdir penyet/
rmdir: penyet/: Directory not empty

Solution

Add -rf (recursive and force) to the rm command to delete the directory and together with the contents inside.

# rm -rf /penyet

Alternatively, you can go inside the directory, delete the contents and remove the directory. This will take time, of course!

# cd penyet/
# rm *
# cd ..
# rmdir penyet/

You May Also Like

Leave a Reply?