The internet is awash with many third-party applications which are used to monitor disk space in Linux. Bash comes with an inbuilt command line tool called df – short for disk filesystem and is used to retrieve a full summary of disk space usage for different filesystems in Linux. In this article, we look at the usage of df command to check disk space in Linux.
How to check Filesystem disk usage
To have a general overview of your filesystem disk usage run the df command as shown
df
Sample Output
Filesystem 1K-blocks Used Available Use% Mounted on udev 499312 0 499312 0% /dev tmpfs 101456 8276 93180 9% /run /dev/xvda1 8065444 4383272 3665788 55% / tmpfs 507276 0 507276 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 507276 0 507276 0% /sys/fs/cgroup tmpfs 101456 0 101456 0% /run/user/1000
Displaying disk space in a human-readable format
To check disk space in detail, append the -h flags to display disk space utilization in memory sizes such as bytes, MegaBytes, and Gigabytes
df -h
Sample Output
Filesystem Size Used Avail Use% Mounted on udev 488M 0 488M 0% /dev tmpfs 100M 8.1M 91M 9% /run /dev/xvda1 7.7G 4.2G 3.5G 55% / tmpfs 496M 0 496M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 496M 0 496M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /run/user/1000
Adding the ‘T’ will display the filesystem
df -Th
Sample Output
Filesystem Size Used Avail Use% Mounted on udev 488M 0 488M 0% /dev tmpfs 100M 8.1M 91M 9% /run /dev/xvda1 7.7G 4.2G 3.5G 55% / tmpfs 496M 0 496M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 496M 0 496M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /run/user/1000
Displaying disk space usage on all file systems
To display all information on the file systems’ disk usage, run the command below
df -a
Sample Output
Filesystem 1K-blocks Used Available Use% Mounted on sysfs 0 0 0 - /sys proc 0 0 0 - /proc udev 499312 0 499312 0% /dev devpts 0 0 0 - /dev/pts tmpfs 101456 10820 90636 11% /run /dev/xvda1 8065444 4383632 3665428 55% / securityfs 0 0 0 - /sys/kernel/security tmpfs 507276 0 507276 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 507276 0 507276 0% /sys/fs/cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd pstore 0 0 0 - /sys/fs/pstore cgroup 0 0 0 - /sys/fs/cgroup/blkio cgroup 0 0 0 - /sys/fs/cgroup/freezer cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct cgroup 0 0 0 - /sys/fs/cgroup/perf_event cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio cgroup 0 0 0 - /sys/fs/cgroup/cpuset cgroup 0 0 0 - /sys/fs/cgroup/memory cgroup 0 0 0 - /sys/fs/cgroup/pids cgroup 0 0 0 - /sys/fs/cgroup/hugetlb cgroup 0 0 0 - /sys/fs/cgroup/devices hugetlbfs 0 0 0 - /dev/hugepages mqueue 0 0 0 - /dev/mqueue debugfs 0 0 0 - /sys/kernel/debug systemd-1 - - - - /proc/sys/fs/binfmt_misc fusectl 0 0 0 - /sys/fs/fuse/connections lxcfs 0 0 0 - /var/lib/lxcfs /dev/xvda1 8065444 4383632 3665428 55% /var/lib/docker/aufs tmpfs 101456 0 101456 0% /run/user/1000 binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
Displaying disk space usage of a specific file systems
To display disk usage of a particular file system e.g /dev/shm run the command below
df -Th /dev/shm
sample Output
Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 496M 0 496M 0% /dev/shm
Displaying file system information in bytes
To show your filesystem information in bytes run ,
df -k
Sample Output
Filesystem 1K-blocks Used Available Use% Mounted on udev 499312 0 499312 0% /dev tmpfs 101456 10820 90636 11% /run /dev/xvda1 8065444 4383632 3665428 55% / tmpfs 507276 0 507276 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 507276 0 507276 0% /sys/fs/cgroup tmpfs 101456 0 101456 0% /run/user/1000
Displaying file system information in MegaBytes
To display this information use the -m option
df -m
Sample Output
Filesystem 1M-blocks Used Available Use% Mounted on udev 488 0 488 0% /dev tmpfs 100 11 89 11% /run /dev/xvda1 7877 4311 3551 55% / tmpfs 496 0 496 0% /dev/shm tmpfs 5 0 5 0% /run/lock tmpfs 496 0 496 0% /sys/fs/cgroup tmpfs 100 0 100 0% /run/user/1000
Displaying file system information in Gigabytes
To display filesystem information in Gigabytes run use the -h flag
df -h
Sample Output
Filesystem Size Used Avail Use% Mounted on udev 488M 0 488M 0% /dev tmpfs 100M 11M 89M 11% /run /dev/xvda1 7.7G 4.3G 3.5G 55% / tmpfs 496M 0 496M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 496M 0 496M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /run/user/1000
Displaying information on file system inodes
Use the -i flag to display inodes
df -i
Sample Output
Filesystem Inodes IUsed IFree IUse% Mounted on udev 124828 378 124450 1% /dev tmpfs 126819 509 126310 1% /run /dev/xvda1 1024000 156950 867050 16% / tmpfs 126819 1 126818 1% /dev/shm tmpfs 126819 4 126815 1% /run/lock tmpfs 126819 16 126803 1% /sys/fs/cgroup tmpfs 126819 4 126815 1% /run/user/1000
Displaying a certain filesystem type
To display a file system append -t flag followed by the file system type
df -t ext4
Sample Output
Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 8065444 4413864 3635196 55% /
Excluding a certain file system type from getting displayed
To achieve this use the -x flag followed by the filesystem type
df -x ext4
Sample Output
Filesystem 1K-blocks Used Available Use% Mounted on udev 499312 0 499312 0% /dev tmpfs 101456 10820 90636 11% /run tmpfs 507276 0 507276 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 507276 0 507276 0% /sys/fs/cgroup tmpfs 101456 0 101456 0% /run/user/1000
Wrapping up
We appreciate your time. Feel free to try out the commands above and let us know your feedback. Thank you.