The Cluttered Filesystem
Over months of continuous operation, an Ubuntu Linux server can become littered with “empty” data. Uninstall scripts frequently fail to delete empty configuration folders, and automated backup software sometimes generates 0-byte log files when a process fails to execute. While these empty files take up almost zero physical hard drive space, they clutter your directory listings and can eventually exhaust the server’s “inode” limit (the maximum number of individual files the system can track), causing the server to refuse to save new data. To maintain a clean, organized filesystem, you must periodically hunt down and delete this 0-byte garbage.
Using the find Command with -empty
The Linux find command utilizes the highly specialized -empty flag to filter the hard drive strictly for zero-byte files.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To search the entire
/var/www/directory for completely empty files, type the following command exactly: sudo find /var/www/ -type f -empty- Press Enter and provide your administrator password.
Finding Empty Directories
The command above isolates empty text files and system logs. To search for abandoned folders instead, simply change the type flag from f (file) to d (directory):
sudo find /var/www/ -type d -empty
This will output a list of folders that contain absolutely zero files or subfolders within them, allowing you to quickly delete them and restore order to your directory structure.