In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will show you how to use di, which is a more useful disk information tool than df. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
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. We will discuss the disk information tool di.
Di disk Information tool
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.04Shell-Bash 4.2.45Application-di 4.30A short tutorial
Here are some examples of di tools:
1. Default output
By default, the di command produces an output format that is easy for people to read
Here is an example:
$di
Filesystem 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
Tmpfs / 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, etc., in great detail.
Here is an example:
$di-A
Mount 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.5 G 0.0G 1.5 G 0%
381805 571 381234
/ 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
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-a
Filesystem 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-fuse
Sysfs / 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 command will be enclosed in double quotation marks
Here is an example:
$di-c
S,m,b,u,v,p,T
/ dev/sda6,/,28.1G,20.2G,6.5G,77%,ext4
Udev,/dev,1.5G,0.0G,1.5G,0%,devtmpfs
Tmpfs,/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-g
Filesystem Mount Gibis Used Avail Used fs Type
/ dev/sda6 / 28.1 20.2 6.5 77% ext4
Udev / dev 1.50.0 1.50% devtmpfs
Tmpfs / run 0.3 0.0 0.3 0 tmpfs
Of course, you can see that all size-related values are printed in gigabytes (G).
Similarly, 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 tmpfs
Filesystem Mount Size Used Avail Used fs Type
Tmpfs / 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
Ok 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 devtmpfs
Tmpfs / 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 of all related columns, use the-t option.
Example:
$di-t
Filesystem 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
Tmpfs / 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.
Here's how to reverse sort the output:
$di-sr
Filesystem Mount Size Used Avail Used fs Type
Tmpfs / run 300.2M 0.9m 299.3M 0% tmpfs
Udev / 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.
For example, print the name of the mount point with-fm.
Example:
$di-fm
Mount
/
/ dev
/ run
As you can see above, only the name of the mount point is printed.
Similarly, print the type of file system, using-ft
Example:
$di-ft
FsType
Ext4
Devtmpf
Tmpfs
If you want to find it quickly, here are screenshots of other formatting options available.
Advantages provide many advanced features cross-platform disadvantages in most Linux distributions do not have a large number of options to learn this is more useful than df disk information tool di how to use all the content, more and more useful than df disk information tool di how to use related content can search the previous article or browse the following article to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.