To sort these directories by size, making it easy to identify which ones are consuming the most space, we can pipe our du command to the sort utility. If you have a deep structure, we can use the -max-depth=N flag to tell du how many subdirectories deep it should traverse. This gives us a rather granular look at how much space each subdirectory is using. $ du -hĪs you can see, the “Debian-based” and “RHEL-based” directories have two and three subdirectories, respectively. Let’s see what happens if we have a deeper folder structure. The total of all these folders is 44 GB, as indicated in the last line. We can see that the AlmaLinux folder is using 11 GB, and the Debian folder is only using 349 MB. We’ll append the -h (human readable) option so it’s easier to see what kind of space these directories are consuming.
In the following example, we run du on a directory full of Linux ISO files, but it’s only one directory deep. Depending on how deep your folder structure goes, this could be a massive amount of directories, and your terminal will be spammed with a lot of output. When running du without any extra options, keep in mind that it will check the total disk usage of each subdirectory, individually. For checking disk usage by folder, the du command is particularly useful. The df and du command line utilities are the two best tools we have to measure disk consumption on Linux. List directories by size via command line $ – requires given linux commands to be executed as a regular non-privileged user # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command Privileged access to your Linux system as root or via the sudo command. Requirements, Conventions or Software Version Used Listing the biggest directories on Linux Software Requirements and Linux Command Line Conventions Category