
How to check disk usage using df commands
Description
The ‘df‘ command stand for “disk filesystem“, it is used to get full summary of available and used disk space usage of file system on Linux system.
Using ‘-h‘ parameter with (df -h) will shows the file system disk space statistics in “human readable” format, means it gives the details in bytes, mega bytes and gigabyte.
This article explain a way to get the full information of Linux disk space usage with the help of ‘df‘ command with their practical examples.
So, you could better understand the usage of df command in Linux.
1. Check File System Disk Space Usage df
The “df” command displays the information of device name, total blocks, total disk space, used disk space, available disk space and mount points on a file system.
[root@vps ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 41153856 2362628 36677692 7% / devtmpfs 486288 0 486288 0% /dev tmpfs 506216 0 506216 0% /dev/shm tmpfs 506216 57232 448984 12% /run tmpfs 506216 0 506216 0% /sys/fs/cgroup tmpfs 101244 0 101244 0% /run/user/0
2. Display Information of all File System Disk Space Usage df -a
This displays information of dummy file systems along with all the file system disk usage and their memory utilization.
[root@vps ~]# df -a Filesystem 1K-blocks Used Available Use% Mounted on rootfs - - - - / sysfs 0 0 0 - /sys proc 0 0 0 - /proc devtmpfs 486288 0 486288 0% /dev securityfs 0 0 0 - /sys/kernel/security tmpfs 506216 0 506216 0% /dev/shm devpts 0 0 0 - /dev/pts tmpfs 506216 57232 448984 12% /run tmpfs 506216 0 506216 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/memory cgroup 0 0 0 - /sys/fs/cgroup/freezer cgroup 0 0 0 - /sys/fs/cgroup/pids cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct cgroup 0 0 0 - /sys/fs/cgroup/devices cgroup 0 0 0 - /sys/fs/cgroup/blkio cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio cgroup 0 0 0 - /sys/fs/cgroup/hugetlb cgroup 0 0 0 - /sys/fs/cgroup/perf_event cgroup 0 0 0 - /sys/fs/cgroup/cpuset configfs 0 0 0 - /sys/kernel/config /dev/xvda1 41153856 2362628 36677692 7% / selinuxfs 0 0 0 - /sys/fs/selinux systemd-1 - - - - /proc/sys/fs/binfmt_misc debugfs 0 0 0 - /sys/kernel/debug mqueue 0 0 0 - /dev/mqueue hugetlbfs 0 0 0 - /dev/hugepages binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc tmpfs 101244 0 101244 0% /run/user/0
3. Show Disk Space Usage in Human Readable Format df -h
Have you noticed that above commands displays information in bytes, which is not readable yet all, because we are in a habit of reading the sizes in megabytes, gigabytes etc. as it makes very easy to understand and remember.
The df command provides an option to display sizes in Human Readable formats by using ‘-h’ (prints the results in human readable format (e.g., 1K 2M 3G)).
[root@vps ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 40G 2.3G 35G 7% / devtmpfs 475M 0 475M 0% /dev tmpfs 495M 0 495M 0% /dev/shm tmpfs 495M 56M 439M 12% /run tmpfs 495M 0 495M 0% /sys/fs/cgroup tmpfs 99M 0 99M 0% /run/user/0
4. Display Information of /home File System df -hT /home
To see the information of only device /home file system in human readable format use the following command.
[root@vps ~]# df -hT /home Filesystem Type Size Used Avail Use% Mounted on /dev/xvda1 ext4 40G 2.3G 35G 7% /
5. Display Information of File System in Bytes df -k
To display all file system information and usage in 1024-byte blocks, use the option ‘-k‘ (e.g. –block-size=1K) as follows.
[root@vps ~]# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 41153856 2362636 36677684 7% / devtmpfs 486288 0 486288 0% /dev tmpfs 506216 0 506216 0% /dev/shm tmpfs 506216 57232 448984 12% /run tmpfs 506216 0 506216 0% /sys/fs/cgroup tmpfs 101244 0 101244 0% /run/user/0
6. Display Information of File System in MB
To display information of all file system usage in MB (Mega Byte) use the option as ‘-m‘.
[root@vps ~]# df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/xvda1 40190 2308 35819 7% / devtmpfs 475 0 475 0% /dev tmpfs 495 0 495 0% /dev/shm tmpfs 495 56 439 12% /run tmpfs 495 0 495 0% /sys/fs/cgroup tmpfs 99 0 99 0% /run/user/0
7. Display Information of File System in GB
To display information of all file system statistics in GB (Gigabyte) use the option as ‘df -h‘.
[root@vps ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 40G 2.3G 35G 7% / devtmpfs 475M 0 475M 0% /dev tmpfs 495M 0 495M 0% /dev/shm tmpfs 495M 56M 439M 12% /run tmpfs 495M 0 495M 0% /sys/fs/cgroup tmpfs 99M 0 99M 0% /run/user/0
8. Display File System Inodes
Using ‘-i‘ switch will display the information of number of used inodes and their percentage for the file system.
[root@vps ~]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 2621440 57713 2563727 3% / devtmpfs 121572 287 121285 1% /dev tmpfs 126554 1 126553 1% /dev/shm tmpfs 126554 373 126181 1% /run tmpfs 126554 16 126538 1% /sys/fs/cgroup tmpfs 126554 1 126553 1% /run/user/0
9. Display File System Type
If you notice all the above commands output, you will see there is no file system type mentioned in the results.
To check the file system type of your system use the option ‘T‘. It will display file system type along with other information.
[root@vps ~]# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/xvda1 ext4 41153856 2362648 36677672 7% / devtmpfs devtmpfs 486288 0 486288 0% /dev tmpfs tmpfs 506216 0 506216 0% /dev/shm tmpfs tmpfs 506216 57232 448984 12% /run tmpfs tmpfs 506216 0 506216 0% /sys/fs/cgroup tmpfs tmpfs 101244 0 101244 0% /run/user/0
10. Include Certain File System Type
If you want to display certain file system type use the ‘-t‘ option.
For example, the following command will only display ext3 file system.
[root@vps ~]# df -t ext3 Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p2 78361192 23190072 51126356 32% / /dev/cciss/c0d0p5 24797380 22273432 1243972 95% /home /dev/cciss/c0d0p3 29753588 25503792 2713984 91% /data /dev/cciss/c0d0p1 295561 21531 258770 8% /boot
11. Exclude Certain File System Type
If you want to display file system type that doesn’t belongs to ext3 type use the option as ‘-x‘.
For example, the following command will only display other file systems types other than ext3.
[root@mvps ~]# df -x ext3 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 41153856 2362648 36677672 7% / devtmpfs 486288 0 486288 0% /dev tmpfs 506216 0 506216 0% /dev/shm tmpfs 506216 57232 448984 12% /run tmpfs 506216 0 506216 0% /sys/fs/cgroup tmpfs 101244 0 101244 0% /run/user/0
12. Display Information of df Command.
Using ‘–help‘ switch will display a list of available option that are used with df command.
[root@vps ~]# df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include dummy file systems -B, --block-size=SIZE use SIZE-byte blocks -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) -H, --si likewise, but use powers of 1000 not 1024 -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) -P, --portability use the POSIX output format --sync invoke sync before getting usage info -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. Report bugs to <bug-coreutils@gnu.org>.
We hope you’ve found this useful!