Best Useful Linux DF Command With Examples

In this article, we are going to discuss on Linux df command. df command (also referred to as Disk Free) is a Linux and Unix operating system related command used to check Disk Space/Disk Usage. not only disk space df command is useful for more than that.

Best Useful Linux DF Command With Examples
Best Useful DF Command With Examples

You can get below disk and partition related information below using the Linux df command :

  • Partition Name
  • Total Size of the Partition in different Units like GBMBKBBlocks…etc..
  • Used Disk Space
  • Available Disk Space
  • Used Disk Space Percentage
  • Mounted Location
  • File System of the Partition
  • Inode Information of the Partition

To check installed df command Package Version use the below command.

[root@localhost ~]# df --version  # Checking df command Package Version
df (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjörn Granlund, David MacKenzie, and Paul Eggert.

To check Disk Usage information like Used SpaceAvailable SpaceUsed space in PercentageMounted Location we can use df command.

[root@localhost ~]# df   # Checking disk usage Information
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       18339256 2465648  14942024  15% /
tmpfs             506176     224    505952   1% /dev/shm
/dev/sda1         297485   34634    247491  13% /boot

df command with argument -a will show you information of all available file systems including dummy file systems.

[root@localhost ~]# df -a   # Showing all available Disk Usage Information
Filesystem       1K-blocks    Used Available Use% Mounted on
/dev/sda2         18339256 2465648  14942024  15% /
proc                     0       0         0    - /proc
sysfs                    0       0         0    - /sys
devpts                   0       0         0    - /dev/pts
tmpfs               506176     224    505952   1% /dev/shm
/dev/sda1           297485   34634    247491  13% /boot
none                     0       0         0    - /proc/sys/fs/binfmt_misc
vmware-vmblock           0       0         0    - /var/run/vmblock-fuse
gvfs-fuse-daemon         0       0         0    - /root/.gvfs

You can use df command with argument -h to check disk usage in Human Readable format.

[root@localhost ~]# df -h  # Checking Disk Usage in Human Readable Format
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        18G  2.4G   15G  15% /
tmpfs           495M  224K  495M   1% /dev/shm
/dev/sda1       291M   34M  242M  13% /boot

You can check the disk usage of a Particular Mount Point by using the Linux df command with the mount point. Refer to the below command.

[root@localhost ~]# df -h /boot/  # Checking Disk Usage of a Particular Mount Point
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       291M   34M  242M  13% /boot

Also, you can check disk usage of a Particular Partition by using the df command with Partition Name. Refer to the below command,

[root@localhost ~]# df /dev/sda2   # Checking Disk Usage of a Particular Partition
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       18339256 2597164  14810508  15% /

df command with argument -BM will print the disk Usage Space in MB (Megabyte).

[root@localhost ~]# df -BM   # Checking Disk Usage in MB (Megabyte) 
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/sda2         17910M 2408M    14592M  15% /
tmpfs               495M    1M      495M   1% /dev/shm
/dev/sda1           291M   34M      242M  13% /boot

Linux df command with argument -BG will print the disk Usage Space in GB (Gigabyte).

[root@localhost ~]# df -BG  # Checking disk usage in GB (Gigabyte)
Filesystem     1G-blocks  Used Available Use% Mounted on
/dev/sda2            18G    3G       15G  15% /
tmpfs                 1G    1G        1G   1% /dev/shm
/dev/sda1             1G    1G        1G  13% /boot

df command with argument -BK will print the disk Usage Space in KB (Kilobyte).

[root@localhost ~]# df -BK  # Checking Disk Usage in KB (KiloByte)
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda2      18339256K 2465640K 14942032K  15% /
tmpfs            506176K     224K   505952K   1% /dev/shm
/dev/sda1        297485K   34634K   247491K  13% /boot

OR you can refer to the below command to get the same result. df command with argument -k also will print the disk usage in KB.

[root@localhost ~]# df -k  # Checking Disk Usage in KB
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       18339256 2465644  14942028  15% /
tmpfs             506176     224    505952   1% /dev/shm
/dev/sda1         297485   34634    247491  13% /boot

As we know that 1024MB = 1GB. Normally df command calculates the disk usage in this way only. But when you use Linux df command with argument -H then in that case df will calculate and print the disk usage in Powers of 1000 instead of 1024.

[root@localhost ~]# df -H  # Checking Disk Usage in Powers of 1000 Instead of 1024
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        19G  2.6G   16G  15% /
tmpfs           519M  230k  519M   1% /dev/shm
/dev/sda1       305M   36M  254M  13% /boot

To check Inode Information of the Disk you can use df command with argument -i. Here you will get Inode information like Total Number of InodesUsed InodesAvailable Inodes, and so on.

[root@localhost ~]# df -i   # Checking Inode Information
Filesystem      Inodes IUsed   IFree IUse% Mounted on
/dev/sda2      1164592 96621 1067971    9% /
tmpfs           126544     5  126539    1% /dev/shm
/dev/sda1        76912    38   76874    1% /boot

df command with argument -T will print the File System type of the Partition.

[root@localhost ~]# df -T  # To check the Filesystem type of the Partition
Filesystem     Type  1K-blocks    Used Available Use% Mounted on
/dev/sda2      ext4   18339256 2504068  14903604  15% /
tmpfs          tmpfs    506176     228    505948   1% /dev/shm
/dev/sda1      ext4     297485   34634    247491  13% /boot

For more Linux df command information and arguments you can use the below command.

[root@localhost ~]# df --help   # For df command related 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
      --direct          show statistics for a file instead of mount point
      --total           produce a grand total
  -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

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

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 df bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'df invocation'

OR you can use the below command.

[root@localhost ~]# man df  # Linux df command help page

Also ReadUseful Linux Fdisk Command With Examples – A Linux Disk Partition Tool

That’s all, In this article, we have explained Best Useful DF Command With Examples. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.

Share this:
WhatsApp Channel Join Now
Telegram Channel Join Now
Instagram Channel Join Now

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.