DF Command complete tutorial

DF Command in Linux/Unix (Complete Tutorial)

If you are working in Linux and unix systems, You will definitely need to check the free space and other space details of your file system.

df command stands for disk free. For all these purposes DF Command will work.   

What is DF Command?

DF command is an abbreviation of Disk Free. This utility is used to check the available space in file systems and the used space in file system.

DF Command Usage?

There are many situations when you need to find information about available space like  installing any software. FTP transfer of big files. Before doing any big changes, You should check the available space of your file system to ensure the optimal performance of your Linux and Unix systems. 

Here DF command will help you  .

DF Command Syntax?

Command:  df [OPTION]… [FILE]…
Option: Which is compatible with df command
File: Filename or file space name to get the disk details.

DF Command Options

-a: Here a stands for all, It includes types of file system. 
-B: It scales the size in your desired format, like BM
-h: With this option you will get details in human readable format. Print size in power of 1024.
-H: Provide you details in human readable format also, But in powers of 1000
-k: Give details in Block Size.
-l: This DF option limit listings to local file system.
-P: –Portability- use the POSIX output format.
      –sync -invoke sync before getting usage info.
      –total -elide all entries insignificant to available. space,and produce a grand total.
-t: –type=TYPE, It will limit listing to file systems of type TYPE
-T: It will print file system type
-x: It will limit listing to file systems not of type TYPE.

DF Command Examples

Example 1: df command without any option

When you run the df command without any option and file name. It gives the file 

$ df

OUTPUT: df command without any options will give details of the used memory, available memory and where it is mounted on.

Below are the details of df command: 

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git 478487548 82917408 395570140 18% /
D: 123810812 11826364 111984448 10% /d
F: 51199996 97904 51102092 1% /f
H: 307199996 116948 307083048 1% /h

Example 2: df command usage specific file

When you run the df command with specific file name, It provide you the details of mount information of specific file

$ df camtasia

OUTPUT: df command with specific file name, will give details of information of file system where file is located. you can also options in that command. like -h and others. 

$ df camtasia
Filesystem 1K-blocks Used Available Use% Mounted on
D: 123810812 11826364 111984448 10% /d

Example 3: You want details of complete disk space.

When you run the df command with specific file name, It provide you the details of mount information of specific file

$ df -a

OUTPUT: when you use -a option, It give used memory, available memory of all file spaces.

$ df -a
Filesystem 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git 478487548 82495416 395992132 18% /
C:/Program Files/Git/usr/bin – – – – /bin
C:/Users/91989/AppData/Local/Temp – – – – /tmp
C: – – – – /c
D: 123810812 11826364 111984448 10% /d
F: 51199996 97904 51102092 1% /f
H: 307199996 116948 307083048 1% /h

Example 4: df -h for getting details in human readable format

When you ran the command simply df, It will provide the disk space but in bytes which seems difficult to understand, then df -h format will used, you will get the disk space details in human readable format.

$ df -h

OUTPUT: when you use -h option, It give used memory, available memory of all file spaces on format of MB, GB and other understandable formats.

$ df -h
Filesystem Size Used Avail Use% Mounted on
C:/Program Files/Git 457G 79G 378G 18% /
D: 119G 12G 107G 10% /d
F: 49G 96M 49G 1% /f
H: 293G 115M 293G 1% /h

Example 5: df -H for getting details in human readable format in power of 1000

With lowercase h option, bytes will got converted into kb, mb in the power of 1024. And when you use H (Uppercase), It will give you details in the power of 1000. 

$ df -H

OUTPUT: when you use -H option, It give used memory, available memory of all file spaces on format of MB, GB and other understandable formats but in power of 1000.

$ df -H
Filesystem Size Used Avail Use% Mounted on
C:/Program Files/Git 490G 85G 406G 18% /
D: 127G 13G 115G 10% /d
F: 53G 101M 53G 1% /f
H: 315G 120M 315G 1% /h

Example 6: df -k for getting details of disk space in Block size 1k.

If you need the disk space details in 1k Block size, you need to use df -k and also in similar way you can use df -m for getting disk space details in 1M block size.

$ df -k

OUTPUT: when you use -k option, It give used memory, available memory of all file spaces on block size of 1K.

$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git 478487548 82496488 395991060 18% /
D: 123810812 11826364 111984448 10% /d
F: 51199996 97904 51102092 1% /f
H: 307199996 116948 307083048 1% /h

Example 7: df --total for getting total disk space

In other df command options, you got only available and used space, when you use df –total, You will get total space in file system as well.

$ df –total

OUTPUT: when you use –total with df command, You will get total space in 1k Blocks column.

$ df –total
Filesystem 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git 478487548 82495192 395992356 18% /
D: 123810812 11826364 111984448 10% /d
F: 51199996 97904 51102092 1% /f
H: 307199996 116948 307083048 1% /h
total 960698352 94536408 866161944 10% –

Example 8: df --sync for sync of disk space

BY default, df command will run in nosync mode, If you need to call sync function you should use df –sync.

$ df –sync

OUTPUT: This command just sync all the file space system and provide you the details.

$ df –sync
Filesystem 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git 478487548 82498584 395988964 18% /
D: 123810812 11826364 111984448 10% /d
F: 51199996 97904 51102092 1% /f
H: 307199996 116948 307083048 1% /h

Example 9: df -i to check inodes

for checking inodes details, You need to use the option df -i

$ df –i

Example 10: df -T for printing file type system

If you need yo know about file type system, you should use df -T 

$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
C:/Program Files/Git ntfs 478487548 82579728 395907820 18% /
D: ntfs 123810812 11826364 111984448 10% /d
F: ntfs 51199996 97904 51102092 1% /f
H: ntfs 307199996 116948 307083048 1% /h

This is all for df command. Let us know in comments if you know any other options in df command. 

Thanks Happy learning.

Leave a Comment

Your email address will not be published. Required fields are marked *