Thursday, 24 October 2013

In my previous articles, I have already covered two different Linux commands used for monitoring the disk usage statistics in your Linux systems, that are- 'df' Command and 'du' Command. If you have not read these articles, you can read it now:

In this article, we will see a new command 'di' that has the same function as that of 'df' command and 'du' command along with some advanced features. 'di' stands for 'Disk Information' and it has all the features supported by the well-known 'df' command, hence can be considered as an alternative for 'df' command. If you observe and compare outputs of 'df'' command and 'di' command, you will find that there is an extra column of 'Total Size' of the file system in the 'di' command output. So, without much a do, lets jump to the tutorial part of this article.

Here we go!

1. Basic Usage of 'di' Command

When 'di' command is executed without any options and arguments, it will produce an output which is easily understandable by a human being. It uses notations like 'G' for gigabytes and 'M' for megabytes. It is definitely better that the 'df' output which displays the disk space usage in terms of number of data blocks occupied.

Example:

di

Result:

Result: di

2. Displaying All Fields

When di command is used with option -A, it displays mount points and special devices names at full width.

Example:

di -A

Result:

Result: di -A

3. Displaying All Mounted Devices

When 'di' command is executed with option -a, it displays information about all the currently mounted devices.

Example:

di -a

Result:

Result: di -a

4. Displaying the Comma Separated Values

When 'di' command is used with option -c, it prints the output with comma separated values.

Example:

di -c

Result:

Result: di -c

5. Display Usage in Gigabytes, Megabytes and Kilobytes

If you run 'di' command with options -g, -m and -k, you will get disk usage information in Gigabytes, Megabytes and Kilobytes in the output respectively.

Example:

di -g
di -m
di -k

Result:

Result: di -g, di -m, di -k

6. Print the Information Specific to a Particular File System

When you wish to observe disk space usage stats related to a specific file system, you can use 'di' command with option -I and file system type as an argument.

Syntax:

di -I [FILE SYSTEM]

Example:

di -I ext4

Result:

Result: di -I ext4

7. Do Not Print the Header

When you are parsing the 'di' output, you may not want to print the header line in the output. This can be achieved by executing 'di' command with option -n.

Example:

di -n

Result:

Result: di -n

8. Displaying the Total Usage

You can add an extra line in the 'di' output specifying the total disk space usage information by using option -t.

Example:

di -t

Result:

Result: di -t

That's all. You can always refer to manual page of 'di' command by entering man di in the terminal. For any feedback, use the comment section below and stay tuned for more articles on Linux Commands.