Advanced use of Linux commands du

Source: Internet
Author: User
Tags disk usage

Du command: Disk usage, as the name implies, is about directory usage, and its function is to calculate the size of the directory.

1.

To see the size of all directories and subdirectories in the current directory:

# du-h.

“.” Represents the current directory. can also be replaced by a clear path

-h means to display the human form of K, M and G

2.

Just want to see the size of the ABC directory under the current directory, and don't want to look at other directories and their subdirectories:

# DU-CH ABC | Tail-n 1

This method requires pipeline technology to pipe du and tail two commands to implement.

-C indicates that the sum of the sizes of all listed directories is finally calculated

# DU-SH ABC

-S means that a summary value is listed only

# du-h–max-depth=0 ABC

–max-depth=n means that only deep into the nth-level directory, where set to 0, means not to go deep into subdirectories.

3.

Lists the size of all directories and files under the ABC directory and its subdirectories:

# Du-ah ABC

-a means including directories and files

4.

Lists the size of the directory names in all ABC directories that do not include the XYZ string:

# du-h–exclude= ' *xyz* ' ABC

5.

To get more information about the ABC directory and the size of subdirectories on one screen:

# du-0h ABC

0 (bar 0) indicates the information for each directory listed, not wrapping, but outputting the information of the next directory directly.

Du and DF are often used together, sometimes with insufficient disk space, to find large disk space paths next to each other. You can also use the Find command to view the location of large files.

The most I use is du-sh *; ---can list the size of all files and folders in the current directory.

Advanced use of Linux commands du

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.