The Silent Clutter
Over time, an Ubuntu Linux server can accumulate thousands of “zero-byte” files. These are completely empty files generated by broken scripts, failed downloads, or application errors. While they take up almost zero physical disk space, they consume finite “inodes” (index nodes) in the Linux filesystem. If your server runs out of inodes, the operating system will completely crash and refuse to create new files, even if you technically have hundreds of gigabytes of free storage available. To prevent this silent failure, you must periodically locate and delete these ghost files.
Using the find Command with -empty
The Linux find command utilizes the highly specific -empty flag to scan the hard drive explicitly for files that contain exactly zero bytes of data.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To scan the
/tmp/directory and only return files that are completely empty, type the following command exactly: sudo find /tmp/ -type f -empty- Press Enter and provide your administrator password.
Targeting Empty Directories
The -empty flag works on both files and folders. If a script creates hundreds of nested folder structures but fails to actually write any data inside them, you can modify the command to isolate these empty directories. Simply change the type flag from f (file) to d (directory): sudo find /var/ -type d -empty. This instructs the search engine to ignore all standard files and only return a list of folders that contain absolutely nothing, allowing you to quickly clean up corrupted directory trees.