Good Linux question — answering as the UphillTech team:
First I wold suggest you to use the command df to get the free space. Also you should provide a system path (for example / ) or device name (for example /dev/sda1 ) to make the things simple. The output of the command df / executed on my VPS looks like: $ ssh -n user@host "df /" Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 25671932 8335064 16009768 35% / We need only the available space so we can filter the output by the help of awk (for example): $ ssh -n user@host "df /" | awk 'NR > 1 {print $4; exit}' 16009768 Second use the same units as the output of the above command...
Full answer by pa4080: https://askubuntu.com/a/1061344 (CC BY-SA 4.0).
Need Linux help for your business? UphillTech.