Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the disk Information tool di in Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "Linux disk information tool di how to use", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the disk information tool di in Linux" this article.

If you are a Linux command line user, you will certainly use the df command to check the disk usage of the file system. Although df is a popular command, it still doesn't provide some advanced features, such as a user's actual free disk space, and various useful display formats. There is another command-line utility available that provides not only these advanced features but also all the features of df. In this article, we will discuss the disk information tool-di.

Di-disk Information tool di disk Information tool di

It is clear from this di help man page that di provides some valuable features that are worth a try. Let's look at some examples of the actual use of this tool.

Test environment

OS-Ubuntu 13.04 Shell-Bash 4.2.45 Application-di 4.30

A short tutorial

Here are some examples of di tools:

1. Default output

By default, the di command produces an easy-to-read output format, and here's an example:

$diFilesystem Mount Size Used Avail% Used fs Type/dev/sda6 / 28.1G 20.2G 6.5G 77% ext4 udev / dev 1.5G 0.0G 1.5G 0% devtmpfstmpfs / run 300.2M 0.9M 299.3M 0 tmpfs

So you can find data units of disk usage in gigabytes (G) and megabytes (M). This is definitely better than the default output of df. (translation note: df can also output a display with similar units, but with an additional parameter of-h)

two。 Use the-An option to print all fields such as mount point, special device name, etc.

Option-A can be used to print mount points, special device names, and so on in great detail. Here is an example:

Di-AMount fs Type Filesystem Options Size Used Free% Used% Free Size Used Avail% Used% Free Size Used Avail% Used Inodes Iused Ifree% Iused/ ext4 / dev/sda6 rw Errors=remount-ro 28.1G 20.2G 8.0G 72% 28% 28.1G 21.6G 6.5G 77% 23% 26.7G 20.2G 6.5G 75% 1884160 389881 1494279 21%/dev devtmpfs udev rw Mode=0755 1.5G 0.0G 1.5G 0% 100% 1.5G 0.0G 1.5G 0% 100% 1.5G 0.0G 1.5G 0% 381805 571 381234 0%/run tmpfs tmpfs rw,noexec,nosuid,size=10% Mode=0755 300.2M 0.9M 299.3M 0% 100% 300.2M 0.9M 299.3M 0% 100% 300.2M 0.9M 299.3M 0% 384191 549 383642 0

So you can see all the fields that can be used to print out for debugging purposes.

3. Print all mounted devices with the-an option

Here is an example:

$di-aFilesystem Mount Size Used Avail% Used fs Type / dev/sda6 / 28.1G 20.2G 6.5G 77% ext4 udev / dev 1.5G 0.0G 1.5G 0% devtmpfs devpts / dev/pts 0.0M 0.0M 0.0M 0% devpts proc/ proc 0.0M 0.0M 0.0M 0% proc binfmt_misc / proc/sys/fs/bi 0.0M 0.0M 0.0M 0% binfmt_misc tmpfs / run 300.2M 0.9m 299.3M 0% tmpfs none / run/lock 0.0M 0.0M 0.0M 0% tmpfs none / run/shm 0.0M 0.0M 0.0M 0% tmpfs none / run/user 0.0M 0. 0M 0.0M 0% tmpfs gvfsd-fuse / run/user/himan 0.0M 0.0M 0.0M 0% fuse.gvfsd-fusesysfs / sys 0.0M 0.0M 0.0M 0% sysfs none / sys/fs/cgroup 0.0M 0.0M 0.0M 0 tmpfs none / sys/fs/fuse/co 0.0M 0.0M 0.0M 0% fusectl none / sys/kernel/deb 0.0M 0.0M 0.0M 0% debugfs none / sys/kernel/sec 0.0M 0.0M 0.0M 0 securityfs

So you can see all the information related to all the devices, which is printed out.

4. Use the-c option to use a comma as the value delimiter

Option-c values separated by commands will be enclosed in double quotation marks, here is an example:

$di-cs,m,b,u,v,p,T/dev/sda6,/,28.1G,20.2G,6.5G,77%,ext4udev,/dev,1.5G,0.0G,1.5G,0%,devtmpfstmpfs,/run,300.2M,0.9M,299.3M,0%,tmpfs

As above, you can see that the value printed with a comma separator is printed. (translation note: this output is easy to parse as input to other programs)

5. Print the size in gigabytes (G) with the-g option

Here is an example:

$di-gFilesystem Mount Gibis Used Avail% Used fs Type/dev/sda6 / 28.1 20.2 6.5 77% ext4 udev / dev 1.50.0% devtmpfstmpfs / run 0.3 0.0 0.3% tmpfs

Of course, you can see that all size-related values are printed in gigabytes (G), and you can use the-k and-m options to display kilobytes (K) and megabytes (M), respectively.

6. Display information about a specific file system type through the-I option

Suppose you want to display information that is only relevant to the tmpfs file system. The following will show you how to complete the task with the-I option.

$di-I tmpfsFilesystem Mount Size Used Avail% Used fs Typetmpfs / run 300.2M 0.9M 299.3M 0% tmpfs none / run/lock 5.0M 0.0M 5.0M 0% tmpfs none / run/shm 1.5G 0.0G 1.5G 0% tmpfs none / run/user 100.0M 0.0M 100.0M 0% tmpfs none / sys/fs/cgroup 0.0M 0.0M 0.0M 0 tmpfs

You can see that only the file system information related to the tmpfs type is output and displayed.

7. Skip the output of the title line with the-n option

If you are trying to parse the output of the command through a script (or program) and want the di command to skip the displayed title line, using the-n option is a great way, here is an example:

$di-n/dev/sda6 / 28.1G 20.2G 6.5G 77% ext4 udev / dev 1.5G 0.0G 1.5G 0% devtmpfstmpfs / run 300.2M 0.9M 299.3M 0% tmpfs

As above, you can see that the title line is not displayed in the output.

8. Print another total line under the file system list with the-t option

If you want to display the total number of all related columns, use the-t option, for example:

$di-tFilesystem Mount Size Used Avail% Used fs Type/dev/sda6 / 28.1G 20.2G 6.5G 77% ext4 udev / dev 1.5G 0.0G 1.5G 0% devtmpfstmpfs / run 300.2M 0. 9m 299.3M 0% tmpfs Total 29.9G 20.2G 8.3G 72%

Observe that the value of the last line is statistics for all file systems.

9. Sort the output with the-s option

The-s option can be used to sort the output of the command, and here's how to reverse the output:

$di-srFilesystem Mount Size Used Avail% Used fs Typetmpfs / run 300.2M 0.9M 299.3M 0% tmpfsudev / dev 1.5G 0.0G 1.5G 0% devtmpfs/dev/sda6 / 28.1G 20.2G 6.5G 77 ext4

You can also add the suboption'r'to reverse sort the output after-s. Similarly, you can use the-s option to do some other types of sorting, here is an excerpt from the man manual for your reference:

-s sort mode

You can specify how to sort. The default sort method is sorted by the name of the mount point. The following sorting methods are supported:

M: sort by mount point name (default)

N: no sorting (that is, in the order in the mount table / etc/fstab)

S: by special device name

T: by file system type

R: sort in reverse order

Sorting methods can be combined, such as: di-stsrm: sort by type, device, mount point in reverse order. Di-strsrm: sort by type, device reverse order, mount point reverse order.

10. Specify the output format with the-f option

You can specify the output format string by combining the-f option with its suboptions, such as-fm, to print the name of the mount point:

$di-fmMount / / dev / run

As you can see above, only the name of the mount point is printed. Similarly, the type of the print file system is-ft, for example:

$di-ftfsTypeext4 devtmpftmpfs

If you want to find it quickly, here are screenshots of other formatting options available.

The above is all the contents of the article "how to use di, a disk information tool in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report