In this short article, we would like to show how to print currently free and used space under Linux/Unix using Bash.
Quick solution (run the following command):
-h causes printing in human-readable format (KB, MB, GB).
Filesystem Size Used Avail Use% Mounted on udev 2.0G 0 2.0G 0% /dev tmpfs 395M 40M 356M 11% /run /dev/sda1 50G 48G 0 100% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs 395M 0 395M 0% /run/user/1001
- at first, we need to find mounting point that keeps data
(in our case all tings are stored in the same place:
- we can see the device
50GB, is used
48GB, is available