DF and Du commands

Source: Internet
Author: User
Tags inode usage

Original

Detailed DF command usage

    • A: displays the disk usage of all file systems and partitions.
    • I: displays the I-nodes usage.
    • K: The size is represented by K (default)
    • T: displays the disk usage of all partitions in a file system.
    • X: displays the disk usage of all partitions of a file system.
    • T: displays the file system name of each partition.

Common commands:DF-Hi

Operation Details

Reference
The command DF can display the maximum available space and usage of all file systems. See the following example:

# DF-H
Filesystem size used avail capacity mounted on
/Dev/ad0s1a 1.9g 389 m 1.4G 21%/
Devfs 1.0 K 1.0 K 0b 100%/dev
/Dev/ad0s1d 989 M 54 K 910 m 0%/tmp
/Dev/ad0s1f 4.8g 3.8g 657 M 86%/usr
/Dev/ad0s1e 1.9g 149 m 1.6g 8%/var
/Dev/ad0s1g 26G 890 K 24g 0%/volume2
/Dev/da0s1d 325g 261g 38g 87%/volume1

The-H parameter is added to indicate that the "human-readable" output is used, that is, the file system uses readable formats such as GB and MB.

The first and last fields output by the preceding command are the File System and Its mount point. We can see that the/dev/ad0s1a partition is mounted under the root directory. We mentioned in the previous section that ad represents the IDE hard disk, while S1 represents the first primary sector. I have another SCSI hard disk named Da, which has a large capacity and is mainly used to store data. Devfs is a special file system. It is not a real disk, but a Virtual File System that FreeBSD uses to manage system hardware devices.

The following four fields, size, used, avail, and capacity, are the capacity, used size, remaining size, and percentage of the shard. When the hard disk capacity is full, you may see that the percentage used exceeds 100%, because FreeBSD will leave some space for the root, so that when the root file system is full, you can also write something to the file system for management.

In addition, we can also use parameter-I to view the current inode usage of the file system. Sometimes, although the file system still has space, if there is not enough inode to store the file information, it will not be able to add new files.

# DF-ih 
Filesystem size used avail capacity iused ifree % iused mounted on
/Dev/ad0s1a 1.9g 389 m 1.4G 21% 20495 262127/
Devfs 1.0 K 1.0 K 0b 100% 0 0 100%/dev
/Dev/ad0s1d 989 M 62 k 910 m 0% 24 141286 0%/tmp
/Dev/ad0s1f 4.8g 3.8g 657 M 86% 311439 348015/usr
/Dev/ad0s1e 1.9g 149 m 1.6g 8% 1758 280864/var
/Dev/ad0s1g 26G 890 K 24g 0% 12 3532786 0%/volume2
/Dev/da0s1d 325g 261g 38g 87% 707277 43311409/volume1
We can see that the number of inode used in the root directory is 20495, and there are 262127 available inode.

Tips
Do you still remember what inode is? Inode is the basic information (metadata) used to store archives and directories, including the time, file name, user, and group. When dividing a sector, the system will first make a bunch of inode for later use. The number of inode is related to the total number of files and directories that can be created in the system. If most of the files to be stored are small, there will be a large number of files on hard disks of the same size, that is, a large number of inode are required to mount files and directories.

Du: query the disk space used by an archive or directory

    • A: displays the disk space occupied by all directories and each file in the second directory.
    • B: The size is represented by bytes (the default value is K bytes)
    • C: add the total value (default)
    • S: only display the total size of each file (summarize)
    • X: only calculate the files of the same file system.
    • L: Calculate the size of all files

Common commands:Du-

Operation Details

Reference
The command du can display the disk space occupied by all files in each directory in the unit of subdirectories in the specified directory. For example:

# Du-H/etc
104 K/etc/defaults
6.0 K/etc/X11
8.0 K/etc/Bluetooth
4.0 K/etc/gnats
52 K/etc/ISDN
388 K/etc/mail
68 K/etc/mtree
2.0 k/etc/NTP
38 K/etc/PAM. d
44 K/etc/periodic/daily
6.0 K/etc/periodic/monthly
42 k/etc/periodic/security
16 K/etc/periodic/weekly
110 K/etc/periodic
6.0 K/etc/PPP
318 K/etc/rc. d
2.0 k/etc/skel
130 K/etc/ssh
10 K/etc/SSL
1.7 m/etc
The-H parameter is used to display the human-readable format. In the application, we can use the "du" command to check which directory occupies the most space. However, the output result of DU is usually very long. We can add the-S parameter to omit the subdirectories in the specified directory, and only display the total combination of the directories:

# Du-SH/etc
1.7 m/etc
When viewing the usage of the Directory, we can export the output results to the sort command for sorting to know which file has used the most space:

# Du/etc | sort-Nr | more
1746/etc
388/etc/mail
318/etc/rc. d
130/etc/ssh
110/etc/periodic
104/etc/defaults
68/etc/mtree
52/etc/ISDN
44/etc/periodic/daily
42/etc/periodic/security
38/etc/PAM. d
16/etc/periodic/weekly
10/etc/SSL
8/etc/Bluetooth
6/etc/PPP
6/etc/periodic/monthly
6/etc/X11
4/etc/gnats
2/etc/skel
2/etc/NTP 
The-Nr parameter of sort indicates that reverse sorting is performed by numerical sorting. Because we want to sort the directory size, we cannot use the size output of human-readable, otherwise, the directory size may contain letters such as K and M, which may result in incorrect sorting.

 

1> display the disk usage of a directory tree and each subtree
DU/home
This shows the number of disk blocks in the/home directory and each subdirectory.Show only directories, not files

2> display the disk usage of a directory tree and each subtree in 1024 bytes
Du-k/home/
The/home directory and each of its subdirectories show 1024 bytes of disk size.

3> displays the disk usage of a directory tree and each subtree in MB.
Du-M/home/
In the/home/Linux directory and each sub-directory, the number of MB disks is displayed.

4> View the size of all directories and subdirectories in the current directory:
Commonly used DU-H/home
"." Indicates the current directory. You can also change it to a clear path.
-H indicates that the display is displayed in the humanized form of K, M, and G.

5> check the size of the user directory in the current directory. You do not want to view other directories and Their subdirectories:
Du-SH/home Common Methods
-S indicates the meaning of the summary, that is, only one summary value is listed,

6> check the size of each directory/file in the current directory. The file size in the subdirectory is not displayed.
Du-h -- Max-depth = 1.
-- Max-depth = n indicates that only the directory at the nth layer is penetrated. If this parameter is set to 1, the directory is not penetrated into the subdirectory.

7> list the sizes of all directories and files in the user directory and Its subdirectories:
Du-Ah/home
-A indicates including directories and files.

8> List directories in the current directory that do not contain the size of the XYZ string:
Du-h -- exclude = '* XYZ *'

 

[root @ bsso Yayu] # Du-h -- Max-depth = 1 work/testing
27 m Work/testing/logs
35 m Work/testing

[root @ bsso Yayu] # Du-h -- Max-depth = 1 work/testing/*
8.0 K work/testing/func. php
27 m Work/testing/logs
8.1 m Work/testing/nohup. out
8.0 K work/testing/testing_c.php
12 K work/testing/testing_func_reg.php
8.0 K work/testing/testing_get.php
8.0 K work/testing/testing_g.php
8.0 K work/testing/var. php

[Root @ bsso Yayu] #Du-h -- Max-depth = 1 work/testing/logs/
27 m Work/testing/logs/

[Root @ bsso Yayu] #Du-h -- Max-depth = 1 work/testing/logs /*
24 k work/testing/logs/errdate. log_show.log
8.0 K work/testing/logs/pertime_show.log
27 m Work/testing/logs/show. Log

End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.