Linux Command Learning notes: Du command

Source: Internet
Author: User
Tags disk usage

The linux du command also looks at the space used, but unlike the DF command, the Linux du command is a view of the space used by the file and directory disks, or some difference from the DF command.1. Command format:du[Options] [file]2. Command function: Displays the disk usage space for each file and directory. 3. Command parameters:-A or-All displays the size of individual files in the directory. -B OR-bytes Displays the directory or file size, in bytes. -C OR--total Displays the sum of all directories or files in addition to the size of individual directories or files. -K OR--The kilobytes is output in kilobytes (1024bytes). -M or--the megabytes is output in megabytes. -S or--summarize only displays totals, listing only the last added value. -H or--human-readable in k,m,g to improve the readability of the information. -X or--one-file-Xystem the file system at the beginning of processing, if the other different file system directories are skipped. -l< Symbolic Links > or--dereference< Symbolic Links >Displays the source file size of the symbolic link specified in the options. -S or--separate-dirs Displays the size of individual directories without the size of their subdirectories. -x< file > or--exclude-from=< file > in < file >specifies a directory or file. --exclude=< directory or File >Skips over the specified directory or file. -D or--dereference-args Displays the source file size for the specified symbolic link. -H or--si and-The h parameter is the same, but the k,m,g is converted to 1000 units. -L or--count-Links Repeats the hardware-linked files. 4. Use instance: Instance 1: Displays the directory or the space occupied by the file command:duoutput: [[email protected] test]#du608./Test6308./test44./scf/Lib4./scf/service/deploy/Product4./scf/service/deploy/Info A./scf/service/Deploy -./scf/Service4./scf/Doc4./scf/bin +./SCF8./test31288    . [[email protected] test] #说明: Displays only the directory size of subdirectories below the current directory and the total size of the current directory, the bottom 1288 is the total size of the current directory instance 2: Displays the space command for the specified file:dulog2012.log output: [[email protected] test]#duLog2012.log -Log2012.log[[email protected] test] #说明: Instance 3: View the occupied Space command for the specified directory:duSCF output: [[email protected] test]#duSCF4scf/Lib4scf/service/deploy/Product4scf/service/deploy/Info Ascf/service/Deploy -scf/Service4scf/Doc4scf/bin +Scf[[email protected] test] #说明: Instance 4: Displays the Space Command for multiple files:duLog30.Tar. GZ log31.Tar. GZ output: [[email protected] test]#duLog30.Tar. GZ log31.Tar. GZ4Log30.Tar. GZ4Log31.Tar. Gz[[email protected] test] #说明: Instance 5: Show only the size of the sum command:du-s output: [[email protected] test]#du-s1288    . [Email protected] test]#du-s SCF +Scf[[email protected] test]# CD. [Email protected] soft]#du-s Test1288Test[[email protected] soft] #说明: Example 6: Easy-to-read format display commands:du-h Test output: [[email protected] soft]#du-h test608k Test/test6308k Test/test44.0K test/scf/Lib4.0K test/scf/service/deploy/Product4.0K test/scf/service/deploy/Info12K Test/scf/service/deploy16k Test/scf/Service4.0K test/scf/Doc4.0K test/scf/bin32k Test/SCF8.0K test/test31.3MTest[[email protected] soft] #说明: Instance 7: Files and directories show commands: output: [[email protected] soft]#du-AH Test4.0K test/log31.Tar. GZ4.0K test/test13.Tar. GZ0test/Linklog.log0test/test6/log2014.log300k Test/test6/Linklog.log0test/test6/Log2015.log4.0K test/test6/log2013.log300k Test/test6/Log2012.log0test/test6/Log2017.log0test/test6/log2016.log608k Test/Test60test/Log2015.log0test/test4/Log2014.log4.0K test/test4/log2013.log300k Test/test4/log2012.log308k Test/test44.0K test/scf/Lib4.0K test/scf/service/deploy/Product4.0K test/scf/service/deploy/Info12K Test/scf/service/deploy16k Test/scf/Service4.0K test/scf/Doc4.0K test/scf/bin32k Test/SCF4.0K test/log2013.log300k Test/Log2012.log0test/Log2017.log0test/Log2016.log4.0K Test/log30.Tar. GZ4.0K Test/log.Tar. bz24.0K Test/log.Tar. GZ0test/test3/Log2014.log4.0K test/test3/Log2013.log8.0K test/test34.0K TEST/SCF.Tar. GZ1.3MTest[[email protected] soft] #说明: Instance 8: Shows how many files or directories each occupy the size of disk space, and also the sum of their commands:du-C log30.Tar. GZ log31.Tar. GZ output: [[email protected] test]#du-C log30.Tar. GZ log31.Tar. GZ4Log30.Tar. GZ4Log31.Tar. GZ8total [[email protected] test] #说明: Plus-after the C option, Du shows not only the size of the two directories that each occupy disk space, but also the sum of them in the last line. Example 9: Sort commands by spatial size:du|Sort-nr| Moreoutput: [[email protected] test]#du|Sort-nr| More1288    .608./Test6308./test4 +./SCF -./scf/Service A./scf/service/Deploy8./test34./scf/service/deploy/Product4./scf/service/deploy/Info4./scf/Lib4./scf/Doc4./scf/Bin[[email protected] test] #说明: instance 10: Output the Space command used by each subdirectory in the current directory:du-H--max-depth=1output: [[email protected] test]#du-H--max-depth=1608K./test6308k./test432k./SCF8.0K./test31.3M    . [[email protected] test] #说明:

Linux Command Learning notes: Du command

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.