Snippets

Find the Amount of Free Disk Space in Ubuntu

Posted by I. B. Gd Pramana A. Putra, 06 Aug 22, last updated 06 Aug 22

In order to find the amount of free disk space in your Ubuntu, you can use the df command.

df

The df will display the amount of disk space available on your file system containing each file name and argument. If no file name is given, the space available on all currently mounted file systems will be shown.

The output of executing df command:

root@my-server:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              483032       0    483032   0% /dev
tmpfs             250088    1024    249064   1% /run
/dev/vda1       25226960 4892352  20318224  20% /
tmpfs             500168       0    500168   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs             500168       0    500168   0% /sys/fs/cgroup
/dev/loop1         69504   69504         0 100% /snap/lxd/22753
/dev/vda15        106858    5321    101537   5% /boot/efi
/dev/loop10        48128   48128         0 100% /snap/snapd/16010
/dev/loop5        116736  116736         0 100% /snap/core/13308
/dev/loop3         44928   44928         0 100% /snap/certbot/2133
/dev/loop11        48128   48128         0 100% /snap/snapd/16292
/dev/loop8         44928   44928         0 100% /snap/certbot/2192
/dev/loop4        116736  116736         0 100% /snap/core/13425
/dev/loop7         63488   63488         0 100% /snap/core20/1581
/dev/loop9         63488   63488         0 100% /snap/core20/1587
tmpfs             100032       0    100032   0% /run/user/0

Alternatively, you can use df with -h option:

df - h

With -h option, df will print sizes in human readable format (in powers of 1024 e.g., 1K, 150M, 2G)..

Example output of executing df -h:

root@my-server:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            472M     0  472M   0% /dev
tmpfs           245M  1.0M  244M   1% /run
/dev/vda1        25G  4.7G   20G  20% /
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/loop1       68M   68M     0 100% /snap/lxd/22753
/dev/vda15      105M  5.2M  100M   5% /boot/efi
/dev/loop10      47M   47M     0 100% /snap/snapd/16010
/dev/loop5      114M  114M     0 100% /snap/core/13308
/dev/loop3       44M   44M     0 100% /snap/certbot/2133
/dev/loop11      47M   47M     0 100% /snap/snapd/16292
/dev/loop8       44M   44M     0 100% /snap/certbot/2192
/dev/loop4      114M  114M     0 100% /snap/core/13425
/dev/loop7       62M   62M     0 100% /snap/core20/1581
/dev/loop9       62M   62M     0 100% /snap/core20/1587
tmpfs            98M     0   98M   0% /run/user/0

I love sharing code snippets as most of the time, a quick code example is what we're looking for instead of long-written articles. If you think my code snippets are helpful and save you a lot of time, please consider buying me a cup of coffee :)

Support me via · paypal · buymeacoffee · ko-fi · trakteer
Contributed Snippets
Answer & Responses
    No comments yet

Wanna write a response?

You have to login before write a comment to this post.