Using the find command, it is easy to recursively delete all empty directories. Which empty directories are safe to delete, and which ones are not?

5

1 Answer

You can recursively delete directories in which you put your data (like Documents, Videos, Images, Downloads, etc.), the others into your home directory (e.g. .cache, .gnome, , .ssh), your root, its sub-folders, etc., shouldn't be removed in this way!

A useful and quite safe way to do this is using the rmdir command (with find):

find . -empty -type d -exec rmdir {} + 

It starts in the current working directory.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy