Unix command : df for showing system disk space in CLI

By | November 14, 2014

What is df ? df or diskfree is a standard unix command for Command Line Interface that used to display system disk and amount of your free and used disk space.

If you used this command without adding any arguments or parameter, df will display amount of your system disk in Bytes. In this tutorial we will try some options for df, so with some options you can try df with different formats, example Display in Blocksize, Human Readable mode, and Display as Specific File System. So let’s try it.

First is running df by default without any arguments, open your terminal and type :

$ df

With this command, df will display currently mounted file systems along with total space, free space, used space, display the size as bytes, and mounting directory.

df for showing system disk space in CLI

df

Display format in Block Size

This options allows you to scale the disk different unit arguments, to use this format, type use df command and add some arguments.

$ df -B MB
df for showing system disk space in CLI2.png

df -B MB

We are using block size option with MB, megabytes this will print the full disk space without scaling it. If you need to scale it by 4, use this following command :

$ df -B 4MB
df for showing system disk space in CLI3

df -B 4MB

With this argument the disk will divide by 4.

Human Readable Format

This command will print the output with easier format to read. It shows the unit size in GB, MB, and KB instead of bytes. To display the output in human readable format just add -h option.

$ df -h
df for showing system disk space in CLI4

df -h

Display a Specific File System

With this command, it will display only the file system format, for example if we type ext4, only ext4 partition will be printed.

$  df -h -t ext4
df for showing system disk space in CLI5

df -h -t ext4

For NTSF format use fuseblk, because it’s mounted using NTFS-3G.

$ df -h -t fuseblk
 df for showing system disk space in CLI6

df -h -t fuseblk

For more information about df you can check it manual page by using following command

$ man df

Or by add arguments –help.

$ df --help

Leave a Reply

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