Shell learns to find files in the current directory and folder size-' du ' command and ' DF ' command

Source: Internet
Author: User
Tags readable



After a few days of disk-filled events, I found myself completely unaware of DU's command, so I was determined to learn.



I'll just be a porter, the extranet. Find a tutorial



' Du ' is the size of the Find folder


Du


Typing The above at the prompt gives your a list of directories that exist in the current directory along with their SI Zes. The last line of the output gives your total size of the current directory including its subdirectories. The size given includes the sizes of the files and the directories that exist in the current directory as well as all of I TS subdirectories. Note this by default the sizes given is in kilobytes.



The size of the directory under the current folder is printed, and the last line prints the entire folder, including its subfolders, of the total size,size containing all the files and subdirectories currently recorded. Note that the unit is KB by default


du /home/sunyuw


The above command would give you the directory size of the DIRECTORY/HOME/SUNYUW



This will not turn over, some of the output is as follows:





 
 
528    ./.mozilla/firefox/reo52zta.default/storage/persistent
532    ./.mozilla/firefox/reo52zta.default/storage
13220    ./.mozilla/firefox/reo52zta.default/adblockplus
38788    ./.mozilla/firefox/reo52zta.default
38812    ./.mozilla/firefox
4    ./.mozilla/extensions
38820    ./.mozilla
2080040    .













du -H





This command gives you a better output than the default one. The option '-H ' stands for human readable format. So the sizes of the files/directories is this time suffixed with a ' k ' if it kilobytes and ' M ' if its megabytes and ' G ' If its gigabytes.



This command output is much better than the default (much closer to human reading). The option '-H ' stands for ' human readable format '. So this time the size of files and folders are in the appropriate units as suffixes, such as K, M, G respectively for the KB, MB, GB



Part of the output is this:





13M    ./.mozilla/firefox/reo52zta.default/adblockplus
38M    ./.mozilla/firefox/reo52zta.default
38M    ./.mozilla/firefox 4.0K    ./.mozilla/extensions
38M    ./.mozilla 2.0G    .

 













du -ah





This command would display with its output, not only the directories but also all the files that is present in the current Directory. Note that ' du ' always counts all files and directories while giving the final size of the last line. But the '-a ' displays the filenames along with the directory names in the output. '-h ' is once again human readable format.



Translation: (the landlord of the test) This command will be the entire file under the current folder to traverse the output. It is important to note that Du always outputs all of the file's sum size to the last row, but because of the-a parameter, the file name will be exported separately from the output, but H will still output a human-readable format, some of which are





32K    ./self-learning/intro-linux/sect_03_01.html 8.0K    ./self-learning/intro-linux/sect_07_08.html
12K    ./self-learning/intro-linux/sect_06_01.html
12K    ./self-learning/intro-linux/sect_05_01.html
12K    ./self-learning/intro-linux/sect_01_05.html
800K    ./self-learning/intro-linux/intro-linux.html 8.0K    ./self-learning/intro-linux/sect_05_05.html
16K    ./self-learning/intro-linux/sect_07_01.html 2.7M ./self-learning/intro-linux 9.4M ./self-learning
309M    .




du -C


This is gives you a grand total as the last line of the output. So if your directory occupies 30MB the last 2 lines of the output would be



This will eventually add a total to this line, so if the folder occupies 30MB space then the last two lines will be displayed



The output is as follows:





 
 
305328    ./jumei
800    ./bigchance
284    ./self-learning/Bash-Beginners-Guide/images
1692    ./self-learning/Bash-Beginners-Guide
2920    ./self-learning/advanced bash-guide
752    ./self-learning/intro-linux/images
2748    ./self-learning/intro-linux
9620    ./self-learning
315752    .
315752    total



















du grep Total





This, hehe does not translate, does not explain, can not understand wall to go





du -S


This displays a summary of the directory size. It is the simplest-know the total size of the current directory.



This will output a summary, is the easiest way to get the current folder size



Output:





315752 .




du -S


This would display the size of the current directory excluding the size of the subdirectories that exist within that Direc Tory. So it basically shows your the total size of all the files that is exist in the current directory.



This will each list of files and the size of the folder, this is to query the folder directly under the total size of files method



The output is as follows:





 
 
305328    ./jumei
800    ./bigchance
284    ./self-learning/Bash-Beginners-Guide/images
1408    ./self-learning/Bash-Beginners-Guide
2920    ./self-learning/advanced bash-guide
752    ./self-learning/intro-linux/images
1996    ./self-learning/intro-linux
2260    ./self-learning
4    .





Note that the current folder here has not been computed with the size of sub file or sub dir.





du --exculde=mp3


The above command would display the size of the current directory along with all its subdirectories, but it would Exclude all the files have the given pattern present in their filenames. Thus in the above case if there happens to is any MP3 files within the current directory or any of its subdirectories, the IR size would not being included while calculating the total directory size.



This command will count the size of the current directory and the subdirectory, but will ignore files that match the expression. (not translated later, that is mp3 in this example)



Landlord does not have mp3 placed in the Linux inside, so the output is deployed, the format of reference to the default du command









Next is the DF command, check the disk utilization





Df





Typing the above, outputs a table consisting of 6 columns. All the columns is very easy to understand. Remember the ' Size ', ' used ' and ' Avail ' columns use kilobytes as the unit. The ' use% ' column shows the usage as a percentage which is also very useful.



The output table has 6 elements, each element is easy to understand, remember ' Size ', ' used ', ' Avail ' element in kilobytes, ' use% ' element shows the usage rate as a percentage (this is useful yo).






Not too full, but let's just make a release, haha






Shell learns to find files in the current directory and folder size-' du ' command and ' DF ' command


Related Article

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.