Ubuntu: How can I check all used space on filesystem in linux?


I've already tried du-ch , df -h and df -h --total but it all result to their specific size of folder. Need to know how can I get the total used space in human readable form. Hoping for your help. Thanks in advance.


First of all, let's clarify a few things. When you do df -h --total, there are a few things that show virtual filesystems, such as tmpfs and udev. We don't exactly want that, but we want to know all physical filesystems. As such, we want to filter out only /dev items:

$ df -h | grep '^/dev/'  /dev/sda1       110G   77G   29G  74% /  /dev/sdb6       399G  223G  157G  59% /mnt/HDD  

But there's a problem, too: -h gives us total in human-readable format. We can't really add up items that have letters in them. grep also can't perform calculations. Thus, instead lets use awk instead, with summing the 3rd column:

$ df --block-size=1 | awk '/^\/dev/{total+=$3}END{print total}'                                                            320762605568  

Great ! now we only need to find the human readable version of that number. We can always write code in awk to do that, but there already exists numfmt utility. So we can do this:

$ df --block-size=1 | awk '/^\/dev/{total+=$3}END{print total}' | numfmt --to=iec-i --suffix=B --padding=7                  299GiB  

And that's how you have the total of all physical devices that are mounted ( which is what df shows by default).


You need to use it like so:

df -h --total / | grep total | awk '{ print $3 }'  


df -h --total . | grep total | awk '{ print $3 }'  



Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »