Counting inodes / number of files per directory Print

  • 0

From time to time we experince confusion over storage space utilisation. Namely, "where did all my free space go?" and often, it can be a tricky task tracking down which directories store what data.

So let's say you've navigated to public_html, or whichever directory contains the bulk of your data. Use the following command to get a recursive count of how many files/directories (inodes) are contained within your current directory:
find -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
Remember to be patient! This command can take a long time to complete, especially where your storage speed is slow (i.e. busy server) and/or if you have lots of data.

You could, if you wish, run this from your storage root location to get a full in-depth look at overall storage utilisation, then move up directories as and when required.

Hope this helps!

Was this answer helpful?

« Back