Linux: Show directory size

Actually more of a note to myself, but maybe it helps others. Following scenario: from a directory, the subfolders should be sorted by size.

host:/var# find . -maxdepth 1 -type d -print | xargs du -skm | sort -rn

This input prints all directories below /var, sorted by size, which is output in megabytes. In my case, /var/log is the largest directory. With "-maxdepth 2" you can go one level deeper (output the subdirectories of the subdirectories) and the "." can also be replaced by a concrete path (e.g. "/var/www").

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top