du -ah –max-depth=1 This is the result I want a to show all the files and folders in the directory (excluding subdirectories), h to be human-readable, and MAX-depth to be directory depth.
duThe command is used to see the size of disk space occupied by a directory or file. Common options are: Du -sh
Functions of du: `du` reports the amount of disk space used by the specified files and for each subdirectory(of directory arguments). with no arguments, `du` reports the disk space for the current directory.
Obviously, unlike DF, it is used to see the size of disk space occupied by files or directories.
Two, Du commonly used options:
-h:Display in a human readable manner.
-a:Display the size of disk space occupied by directories, as well as the size of disk space occupied by their directories and files
-s:Display the size of disk space occupied by directories, not the size of disk space occupied by subdirectories and files under them
-c:Displays the size of disk space occupied by several directories or files, and sums up their total.
–apparent-size:Displays the size of a directory or file itself
-l :Statistics hard link takes up the size of disk space
-L:The size of the disk space occupied by the files pointed to by the statistics symbol link.
Du-a: Use this option to display the size of disk space occupied by directories and subdirectories and files in the directory.
As you can see, Du by default only shows the size of disk space occupied by the download directory, and with the – a option, it not only displays the directory (the last line), but also shows the size of disk space occupied by the files in the directory.
3. du-s: When using this option, Du displays only the size of the disk space occupied by the directory, but not the information of the subdirectories and files occupying disk space.
By default, Du does not display disk space information for files in a directory, but it displays disk space information for subdirectories under it; after using the – s option, only the size of disk space occupied by an XX directory is displayed.
Du–apparent-size: Displays the size of the file or directory itself, not the disk space they occupy. Files or directories sometimes do not take up disk space exactly the same size as themselves; this phenomenon is not unique to linux, windowsThis is also true. Let’s look at the explanation of the help document for this option: The apparent size of a file is the number of bytes reported by `wc – c` regularFile, or more general, a file containingThe word `zoo` with no new line will, of course, have an apparent size of 3. Such a small file mayRequire anywhere from 0 to 16 KIB or more of disk space, depending on the type and configuration ofThe file system on which the file resides.
This passage gives the difference between the size of the file or directory itself and the size of the disk space occupied. He gave a more exaggerated example below, and he did not write it here. We know that WC or LS –block-size shows its own size, while Du gives it a footprint.The size of disk space.
Du-c: When you use this option, you not only display the size of the disk space occupied by several files or directories, but also count their total.
As you can see, with the – C option, Du displays not only the size of the disk space occupied by each directory, but also the sum of them on the last line.
Six, Du -l: this option is mainly for hard links. When the statistics directory takes up large disk space, the -l option will also count hard links. The help document is interpreted in this way: Count the size of all files, even if thEy have appeared already (as a hard link).
We set up a hard link in the download directory to point to a file in this directory. When you don’t use the – L option, Du finds hard links pointing to files in this directory, and automatically ignores the linked files to avoid duplicate statistics; only when you use the – L option, does Du unify hard-linked filesCome in.
Seven, Du -L: this option is mainly for symbolic links. It will also count the size of the files that the symbolic links point to occupy the disk space. The help document is interpreted in this way: Dereference symbolic links (show the DIS)K space used by the file or directory that links points to instead of the space used by the link).
We create a symbolic link in the download directory to point to a file in this directory. We see the result of the operation shown in the above image, and when the – L option is used, Du counts the size of the file to which the symbolic link points.
In addition, we look at the results of du-lh, the same as du-h, as if there is no statistical size of symbolic links; in fact, this is not the case. From the practical point of view, symbolic links themselves do not seem to occupy disk space, so this is the case.
Finally, the Du command does not count linked files (either hard links or symbolic links) by default when counting disk space occupied by a directory, so specify it with the – L and – L options; in addition, the Du command does not display disk space occupied by files in a directory by default, but displays its subdirectories by defaultInformation on disk space occupied. Weird.
du -sh : View the total capacity of the current directory. And does not list the capacity of each sub item separately.
du -lh –max-depth=1 : View the disk capacity of primary subfiles and subdirectories in the current directory.