This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has sudo access and that you precede each of the privileged commands with sudo

Linux has a built-in utility to check the Disk Space Utilization named as df.
The df command stands for “disk filesystem”, it is used to get a full summary of available and used disk space usage of the file system on Linux system.

General Syntax

The general syntax of the df command is given below:

root@codesposts:~$ df [options] [devices]

Displaying Information About The df Command

Using --help switch will display a list of available option that is used with df command.

root@codesposts:~$ 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.

Checking File System Disk Space Usage

You can simply type df in the terminal to check the file system disk space usage. It will show the the device file associated with the file system, the total amount of space on the file system, the used space on the file system, the free space on the file system, the percentage of space that’s used, and the mount point. Disk space is shown in 1KB blocks.

root@codesposts:~$ df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda              78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sdc1             29753588  25503792   2713984  91% /data
/dev/sdc2               295561     21531    258770   8% /boot

Checking Disk Space Usage In Human Readable Format

The output of df command is in 1K-blocks which is not easily understandable by us. So, to get the output in more readable format, you can use the option -h with the df command.

root@codesposts:~$ df -h

Filesystem            Size     Used Avail Use% Mounted on
/dev/sda               75G      23G   49G  32% /
/dev/sda2              24G      22G  1.2G  95% /home
/dev/sdc1              29G      25G  2.6G  91% /data
/dev/sdc2             289M      22M  253M   8% /boot

Check File System Of Particular Type

You can display the Disk Space Usage of the file system of a particular type by using the -t option with the df command.

root@codesposts:~$ df -t ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda              78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home

Check Disk Space Usage Of All File Systems

You can display the Disk Space Usage of all the file systems by using the -a option with df command. Unlike the first one, this also displays the dummy file systems and their information.

root@codesposts:~$ df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda              78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
proc                         0         0         0   -  /proc
/dev/sdc1             29753588  25503792   2713984  91% /data
/dev/sdc2               295561     21531    258770   8% /boot
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts

Check Disk Space Usage Of /home File System

To see the information of only device /home file system in human readable format use the following command.

root@codesposts:~$ df -hT /home

Filesystem		Type    Size  Used Avail Use% Mounted on
/dev/sda2	        ext3     24G   22G  1.2G  95% /home

Displaying Information In MBs

To display the information of the File Systems in MBs, you can use -m option with df command.

root@codesposts:~$ df -m

Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda                 76525     22644     49931  32% /
/dev/sda2                24217     21752      1215  95% /home
/dev/sdc1                29057     24907      2651  91% /data
/dev/sdc2                  289        22       253   8% /boot

Display Information In Bytes

To display all file system information and usage in 1024-byte blocks, use the option ‘-k‘ (e.g. --block-size=1K) as follows.

root@codesposts:~$ df -k

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda              78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sdc1             29753588  25503792   2713984  91% /data
/dev/sdc2               295561     21531    258770   8% /boot

Checking File System Inodes

To list available and used inodes, you can use the -i option with df command

root@codesposts:~$ df -i

Filesystem              Inodes     IUsed    IFree IUse% Mounted on
/dev/sda              78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sdc1             29753588  25503792   2713984  91% /data
/dev/sdc2               295561     21531    258770   8% /boot

Displaying The File System Type

To check the file system type of your system use the option -T. It will display file system type along with other information.

root@codesposts:~$ df -T

Filesystem       Type    1K-blocks      Used Available Use% Mounted on
/dev/sda         ext3     78361192  23185840  51130588  32% /
/dev/sda2        ext3     24797380  22273432   1243972  95% /home
/dev/sdc1        ext3     29753588  25503792   2713984  91% /data
/dev/sdc2        ext3       295561     21531    258770   8% /boot

Displaying Information Excluding Particular File System

If you want to display the information of the File Systems that does not belong to a particular type, you use -x option with df command.

root@codesposts:~$ df -T

Filesystem            1K-blocks      Used   Available Use% Mounted on
tmpfs                    257476         0    257476    0%  /dev/shm

THANKYOU