Linux du command: Display file, directory size

Source: Internet
Author: User

Introduced:
The du command displays the space information that the specified file (clip) occupies on the disk. If the specified file parameter is actually a directory, all the files in that directory will be evaluated. If no file parameters are provided, execute the du command to display the file space information in the current directory.

Grammar:

du [-ABCDHHKLMSSX] [-l < symbolic connection;] [--block-size] [--exclude=< directory or file;] [--max-depth=< directory layer;] [directory or file]

option Description:
    -a: Displays the size of individual files in the directory;
    -b: When displaying a directory or file size, in bytes;
    -c: Displays the sum of all directories or files in addition to the size of individual directories or files;
    -d: Displays the source file size of the specified symbolic connection;
    -h: To improve the readability of the information in the K,M,G unit;
    -h: Same as-h parameter, but K,m,g is converted to 1000 units;
    -k: in bytes units;
    -l: Repeat the hard-link file calculation;
    -L< symbol Connection;: Displays the source file size of the symbolic link (soft link) specified in the options;
    -m: The unit is in 1MB;
    -s: Displays the total size;
    -s: When displaying the size of an individual directory, it does not contain the size of its subdirectories;
    -x: The file system at the beginning of processing, if encountered in other different file system directory is skipped;
     -- exclude=< directory or file;: Skip the specified directory or file;
     -- max-depth=< directory layer;: After the specified number of layers, the directory is ignored;

Example of execution:

>$ du #显示当前目录和所有子目录的大小 in KB
0212./dir1/sub1
0312./dir1/sub2
0456./dir2
0584./dir3
0648./dir4
071464.
08$ du-sh #显示当前目录总大小, plus-H improves readability of information
091.5M.
10$ du--max-depth=1-h #显示当前目录和第一层子目录的大小
1124K./dir1
1256K./dir2
1384K./dir3
1448K./dir4
151.5M.

Extended reading:
It is believed that people who use Linux for a long time must have experienced the problem of defragmenting the disk (because the disk space will be full). Want to know which folders are too large to delete some large and useless files. The du command can be very useful at this time. In your user directory, enter:
Du–max-depth=1-h
See which folders are too large, then go into those folders, then keep du–max-depth=1-h, filter out the files you want to delete, then RM ..., you're done!

Linux du command: Display file, directory size

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.