↑ ↓ select, Enter open, Esc close

Find directories with the most files

Adjust the values, the command updates live
user@server
du --inodes -x -d 1 /var/www/vhosts 2>/dev/null | sort -rn | head -20

Counts the inodes (files, directories, links) in each direct subdirectory and sorts them in descending order. When df -i is at its limit, this lets you drill down level by level to the directory with huge numbers of small files. Common culprits are cache folders of WordPress plugins and session directories.

Note: On very large trees this takes a while, since every entry is visited individually.

Also searched as

  • which directory uses the most inodes
  • count files per directory linux
  • find folder with millions of files
  • where are all the small files

Related one-liners

All in Filesystem

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.