The du command implements a Linux folder in which files are sorted by size __linux

Source: Internet
Author: User
Tags disk usage
1. Df-lh

2. Du-s/usr/* | Sort-rn
This is sorted by byte

3. du-sh/usr/* | Sort-rn
This is sorted by megabytes (M)

4. Select 10 of the preceding
Du-s/usr/* | Sort-rn | Head

5. Select the following 10
Du-s/usr/* | Sort-rn | Tail

Du-h–-max-depth=0 User
du-sh–-max-depth=2 | More


This article introduces the usage of the du command parameter in Linux, and illustrates its usage further with demonstration examples.
Du command feature Description: Statistics the size of the disk space that a folder (or file) occupies.
Syntax: du [-ABCDHHKLMSSX] [-l < Symbolic connection >][-x < file >][--block-size][--exclude=< folder or file] [--max-depth=< Folder Layer >][--help][--version][folder or file]
Frequently used parameters:
-A or-all displays disk usage for each of the specified files, or displays the respective disk usage for each file in the folder.
-B or-bytes displays the folder or file size in bytes.
-C or –total displays the sum of all folders or files in addition to the size of the folder or file.
-D or –dereference-args displays the source file size for the specified symbolic connection.
-H or –human-readable to k,m,g to improve the readability of the information.
The-H or –si is the same as the-h parameter, but the k,m,g is in 1000 as the conversion unit instead of 1024.
-K or –kilobytes in 1024 bytes.
-L or –count-links a file that repeatedly calculates hardware connections.
The source file size for the symbol connection specified in the-l< symbol connection > or –dereference< symbol connection > Display option.
-M or –megabytes is in 1MB.
-S or –summarize displays only totals, that is, the current folder size.
When-S or –separate-dirs displays the size of each folder, it does not contain the size of its subfolders.
-X or –one-file-xystem the file system at the start of the process, and if you encounter a different file system folder, skip.
-x< file > or –exclude-from=< file > specify folder or file in < file >.
–exclude=< folder or File > skips the specified folder or file.
–max-depth=< folder layers > folders that exceed the specified number of layers are ignored.
–help display Help.
–version Displays version number information.
The du command in Linux uses a demo example:
1> to display disk usage for a folder tree and each of its subtrees
Du/home/linux
This displays the number of disk blocks in the/home/linux folder and each of its subfolders.
2> to display disk usage for a folder tree and each subtree in 1024-byte units
Du-k/home/linux
This displays the number of 1024-byte disk blocks in the/home/linux folder and each of its subfolders.
3> displays the disk usage of a folder tree and each of its subtrees in MB
Du-m/home/linux
This displays the number of MB disk blocks in the/home/linux folder and each of its subfolders.
4> displays the disk usage of a folder tree and each of its subtrees in GB
Du-g/home/linux
This displays the number of GB disk blocks in the/home/linux folder and each of its subfolders.
5> View the size of all folders and subfolders under the current folder:
Du-h.
“.” Represents the current folder. can also be replaced by a clear path.
-H indicates a humanized form of K, M, and G
6> View the size of the user folder under the current folder and do not want to look at other folders and their subfolders:
Du-sh User
-S indicates the meaning of the summary, which simply lists a summarized value
Du-h--max-depth=0 User
--max-depth=n indicates that the only depth to the N-tier folder is set to 0, which means that it is not drill-down to subfolders.
7> lists the size of all folders and files under the user folder and its subfolders:
Du-ah User
-A represents the inclusion of folders and files
8> lists the size of folders in the current folder that do not contain XYZ strings:
Du-h–exclude= ' *xyz* '
9> want to list a number of other information about the user folder and subfolder size in one screen:
du-0h User
-0 (Bar 0) represents the information for each folder that is listed, without wrapping, but directly outputting the information for the next folder.
10> only displays all disk usage for a folder tree

Du-s/home/linux

Turn from: http://www.cnblogs.com/mfryf/p/3243211.html

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.