The du command is used to view the size of the disk space occupied by a directory or file. Common option combinations are: Du-sh
One, Du's function: ' Du ' reports the amount of disk space used by the specified files and for each subdirectory (of directory argument s). With no arguments, ' du ' reports the disk space for the current directory.
Obviously, unlike DF, it is used to view the size of the disk space occupied by a file or directory.
Second, du common options:
-H: Displayed in a human-readable way
-A: Displays the amount of disk space occupied by the directory, and also shows the size of the disk space under which the directory and file is being consumed
-S: Displays the amount of disk space occupied by the directory, and does not display the amount of disk space the subdirectory and file occupy
-C: Displays the amount of disk space occupied by several directories or files, and also counts their sums
--apparent-size: Displays the size of the directory or file itself
-L: Statistics hard link takes up disk space size
-L: The amount of disk space the file that the statistical symbolic link points to occupies
One, du-h: This is not much to say.
Du-a: When using this option, displays the directory and directory under which the subdirectories and files occupy the size of disk space.
As you can see, du only displays the size of the disk space used by the download directory by default, and with the-a option, it shows not only the directory (the last row), but also the amount of disk space that each file occupies in the directory.
Du-s: When you use this option, Du displays only the size of the disk space that the directory occupies, not the information that its subdirectories and files consume disk space.
By default, Du does not display information about the disk space used by a file in the directory, but it displays information about its subdirectory footprint, and when the-s option is used, only the size of the disk space consumed by the XX directory is displayed.
Du--apparent-size: Displays the size of files or directories themselves, not the amount of disk space they occupy. The size of a file or directory that consumes disk space is sometimes not exactly the same as the size of its own, which is not unique to Linux, and so is in Windows. We look at the explanation of this option's Help document: The apparent size of a file is the number of bytes reported by ' wc–c ' regular files, or more generally, ' Ls–l–block-size=1 ' or ' stat–format=%s '. For example, a file containing the word ' zoo ' with no newline would, of course, which has an apparent size of 3. Such a small file may require anywhere from 0 to + KiB or more of disk space, depending on the type and configuration of The file system on which the file resides.
This paragraph gives the difference between the size of the file or directory itself and the amount of disk space that is consumed. He has given a more exaggerated example, and it is not written here. We know that the WC or LS--block-size shows its size, and du gives the size of the disk space occupied.
V. DU-C: When using this option, not only does it show how many files or directories each occupy the size of disk space, but also the sum of them.
, with the-C option, Du shows not only the size of the two directories that occupy disk space, but also the sum of them in the last line.
Vi. du-l: This option is mainly for hard links. When the statistics catalog consumes disk space, the-l option also counts hard links. The help document explains this: the Count the size of all Files,even if they has appeared already (as a hard link).
We create a hard link under the download directory, pointing to a file in this directory. When you do not use the-l option, du finds a hard link to a file in this directory, and then automatically ignores the linked file to avoid duplication of statistics; with the-l option, du will also count hard-link files.
Vii. du-l: This option is primarily for symbolic links. It also counts the amount of disk space that the file that the symbolic link points to takes up. The help document explains this: Dereference Symbolic links (show the disk space used by the file or directory, the link points to instead of The space used by the link).
09fa513d269759ee5f74843bb2fb43166d22df1e.jpg (22.68 KB, download number: 0)
Download attachments
2017-11-23 10:09 Upload
We create a symbolic link under the download directory, pointing to a file in this directory. We see the result of the action shown in the image above, and when the-l option is used, Du will also count the size of the file that the symbolic link points to in the directory.
In addition, we look at the results of DU-LH, the same as du-h, as if there is no statistics on the size of the symbolic link; From a practical point of view, the symbolic link itself does not seem to occupy disk space, so the above situation occurs.
Finally, the du command does not statistically link files (either hard links or symbolic links) By default when the statistics catalog occupies disk space, so it is indicated by the-L and-l options, and the du command does not display the information about the disk space used by files in the directory by default, but it defaults to the disk space occupied by its subdirectory. Strange.
View directory footprint under Linux du command function