2.11.15. Analysis of disk space with console commands

Byconnecting to hosting via SSH, you can conduct a manual analysis disk space using the commands below.

In commands:

  • To search not across the entire hosting account, but within a specific directory, specify the path to this directory instead of ~.
  • Instead 5 you can specify the number of files / directories to show in the results.

The five biggest directories are:

du -smh ~/* | sort -rh | head -n 5

The five largest directories, including subdirectories:

du -Sh ~ | sort -rh | head -n 5

The five largest files and subdirectories in a given directory are:

du -sh ~/way/to/catalog/* | sort -rh | head -n 5

Five largest files:

find ~ -type f -exec du -Sh {} + | sort -rh | head -n 5

The five subdirectories of the current directory that occupy the most inodes are:

find . -xdev | cut -d "/" -f 2 | sort | uniq -c | sort -nr | head -n 5

The five directories taking up the most inodes, including subdirectories:

find . -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -nr | head -n 5

Number of inodes occupied by the contents of the current directory (including subdirectories):

find . | wc -l