Linux: Which directory has the most files?

An inode is used for every file in the filesystem. If the system is running out of inodes that means there are some directories with a lot of files in them.

The following command will find the directories with most files.

find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n

The following command list free inodes on all filesystems

df -hi