2.11.15. Analyze disk space using console commands

Once connected to the hosting via SSH, you can manually analyze disk-space using the commands below.

In commands:

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

Five of the largest directories:

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

Five of the largest directories, including subdirectories:

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

Five of the largest files and subdirectories in a specific directory:

du -sh ~/path/to/directory/* | sort -rh | head -n 5

Five of the largest files:

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

Five subdirectories of the current directory that occupy the most inodes:

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

Five directories occupying 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 (with subdirectories):

find . | wc -l
Content

    (2)