Linux


How to list and sort directories and files by size in Linux

This will list all directories at the root level sorted alphabetically with their size printed in an easy to read format

du -sh /*

To list all subdirectories for a specified parent directory, use this command and specify the parent directory path like “usr” in this example.

du -h –max-depth=1 /usr

or run this in for current directory

du -h –max-depth=1 2>/dev/null

List size of files within a directory

ls -s