df command in Linux with options and examples

Hi Friends, Today we will learn about the df command in Linux with options and their examples. The df command is used to check the System disk space usage.

These commands show us the total size, used, and available on the connected system Drive.

Kindly refer the link so you can practice with us while learning the POST, it will take 40 to 50 seconds to boot the image

# df 
output:
Filesystem  1K-blocks  Used   Available Use% Mounted on
/dev/sda1   20960256  4364572 16595684  21%  /
devtmpfs    927268       0    927268    0%   /dev
tmpfs       941780       4    941776    1%   /dev/shm
tmpfs       941780     8952   932828    1%   /run
tmpfs       941780       0    941780    0%   /sys/fs/cgroup
tmpfs       188356       4    188352    1%   /run/user/42
tmpfs       188356      40    188316    1%   /run/user/0

As above output shows us the current usage of the particular partition.

Mostly the important is we are not able to get the output clearly. So, we will use -h option for our understanding.

-h option for human readable

# df -h
output: 
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G  4.2G   16G  21% /
devtmpfs        906M     0  906M   0% /dev
tmpfs           920M  4.0K  920M   1% /dev/shm
tmpfs           920M  8.8M  911M   1% /run
tmpfs           920M     0  920M   0% /sys/fs/cgroup
tmpfs           184M  4.0K  184M   1% /run/user/42
tmpfs           184M   40K  184M   1% /run/user/0

Now we are clear with the output, we are able to understand the usage space on our disk.

-T option will show the types of File System.

# df -Th
output: 
Filesystem  Type      Size  Used Avail Use% Mounted on
/dev/sda1   xfs        20G  4.2G   16G  21% /
devtmpfs    devtmpfs  906M     0  906M   0% /dev
tmpfs       tmpfs     920M  4.0K  920M   1% /dev/shm
tmpfs       tmpfs     920M  8.8M  911M   1% /run
tmpfs       tmpfs     920M     0  920M   0% /sys/fs/cgroup
tmpfs       tmpfs     184M  4.0K  184M   1% /run/user/42
tmpfs       tmpfs     184M   40K  184M   1% /run/user/0

You can see the red highlighted part that is the type of file system for the partition which is on our Server.

-t option will show the specific types of File System.

Command: # df -t xfs

Suppose we have to see all the partition for the xfs, so we have to use -t option with xfs.

Now we have to see the ext4 file system so now we will be look something like this.

Command: # df -t ext4

-i option will show information of an inodes instead of Block usage.

Command: # df -i

This command will show us the Total inodes, used inodes, free inodes on the current system drives that you have on your server.

-B option will show the output in Block Size.

The Block size can be in KB, MB, GB, TB, and PB.

  • This image contains the df commands option -B

If we have to see the Disk space in KB then we have to use k argument in the command.

Command: # df -B k

Now suppose we have to check the Block size in MB, then use m as an argument.

Command: # df -B m

Same for the GB, TB and PB.

Command: # df -B g
Command: # df -B t
Command: # df -B P

–output option will show the required fields in the df command.

Command: # df -h --output=size,used,avail,pcent

So, this command will only show total size, used space, remaining space, and used space in percentage.

So, Let’s learn the fields for df command in details.

  • Filesystem: This field contains the name of the Partition.
  • type: This field contain the type of file system the particular partition has.
  • Size: This field defines the total size of the current Disk by default it shows the output in Block Size.
  • Used: This field shows the used space by your current disk.
  • Avail: This field shows the available space in your current disk.
  • Use%: This is the same as the Used field, the only difference is, that it will show the output in a percentage.
  • Mounted on: It will show the mount point, where the devices are mounted in the system.
A cheat sheet of df command in Linux
1. To check the Disk Space.

Example:
#df 
2. To check the Disk Space in human readable format.

Syntax:
df [option]

Example:
#df -h
3. To check the type of file System.

Syntax:
df [option]

Example:
#df -T
4. To check with particular file system.

Syntax:
df [option] [arugment]

Example:
#df -t ext4
#df -t xfs
5. To exculde the particular file type.

Syntax:
df [option] [argument]

Example:
#df -x ext4
6. To show the output in inodes instead of Block size.

Syntax:
df [option]

Example:
#df -i
7. To show the output as a particular field.

Syntax:
df [option]=[field1,field2,field3...]

Example:
#df --output=size,used,avail
8. To check the Block size in KB, MB and GB.

Syntax:
df [option] [argument]

Example:
#df -B k
#df -B m
#df -B g

Solve the Quiz for the df command

0%

why -h option is there in df command?

Correct! Wrong!

Correct the Syntax?

Please select 3 correct answers

Correct! Wrong!

why df command is used?

Correct! Wrong!

To exclude the particular file system type with df command, Answer please?

Correct! Wrong!

Which option is used to print the file system type?

Please select 3 correct answers

Correct! Wrong!

Answer if you can
Thanks for your valuable time!
To Learn more Basic command you can go to "LINUX BASIC COMMAND SECTION" and Spread the Knowledge Keep Supporting us! Follow us on our ID's: >> Instagram: @tastethelinux_official >>Facebook: https://fb.me/tastethelinuxofficial >>Twitter: @LinuxTaste

Share your Results:

Give your valuable time