How to Find Empty Files and Directories in Linux Using the find Command

Over time, a Linux file system can become cluttered with empty log files, zero-byte configuration templates, and abandoned empty directories left behind by uninstalled applications. These empty assets don’t consume meaningful disk space, but they create a messy, difficult-to-navigate directory structure.

Instead of manually opening every single folder to check if it contains data, you can use a powerful flag within the native find command to instantly locate every completely empty file and directory on your system.

Finding Empty Files

The find command requires a starting location. If you want to search your entire hard drive, you start at the root (/). If you only want to search your personal user folder, start at ~ or /home/username.

  1. Open your terminal.
  2. To search for completely empty files within your current directory (and all of its subdirectories), type the following command:
    find . -type f -empty
  3. Press Enter.

The terminal will print a list of paths leading to every file that contains absolutely zero bytes of data.

(Note: The -type f flag specifically restricts the search to “files,” ensuring directories are ignored).

Finding Empty Directories

If you are trying to clean up an old project folder and want to locate directories that contain no files and no sub-folders, you simply change the type flag.

find . -type d -empty

The -type d flag restricts the search to “directories.” The output will provide a clean list of folders that are completely barren.

How to Automatically Delete the Results

The true power of the find command is its ability to execute secondary commands against the results it discovers. If you want to instantly delete every empty file it finds without reviewing them manually, you can append the -delete flag.

find . -type f -empty -delete

Warning: Use this command with extreme caution. Many applications, especially local web servers and databases, occasionally rely on empty “lock” files or configuration placeholders to function correctly. Blindly deleting every empty file in a system directory like /var or /etc can break critical software. It is highly recommended to run the search command without the delete flag first to review the output.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.