When the size of the disk exceeds the standard, there will be alarm prompts, if you know the DF and du command is a very wise choice.
DF can view the first-level folder size, usage scale, file system and its hang-in points, but there is nothing to file.
Du can view the size of files and folders.
It works well with both. For example, use DF to see which level of directory is too large, and then use DF to see the size of the folder or file, so you can quickly determine the crux of the problem.
The following is a brief introduction
The DF command can show the available space and usage for all current file systems , as shown in the following example:
Here is the code snippet: [Email protected] ~]$ df-h Filesystem Size used Avail use% mounted on /DEV/SDA1 3.9G 300M 3.4G 8%/ /dev/sda7 100G 188M 95G 1%/data0 /DEV/SDB1 133G 80G 47G 64%/data1 /dev/sda6 7.8G 218M 7.2G 3%/var /dev/sda5 7.8G 166M 7.2G 3%/tmp /dev/sda3 9.7G 2.5G 6.8G 27%/usr Tmpfs 2.0G 0 2.0G 0%/dev/shm |
The parameter-H indicates the use of the "human-readable" output, that is, in the file system size using GB, MB and other easy-to-read format.
The first field (Filesystem) and the last field (mounted on) of the above command output are the file system and its hang-in points respectively. We can see that this partition of/DEV/SDA1 is hung in the root directory.
The next four fields size, used, Avail, and use% are the partition's capacity, the size used, the remaining size, and the percentage used. Under FreeBSD, when the hard disk is full, you may see that the percentage used is more than 100%, because FreeBSD leaves some room for root, allowing Root to be managed when the file system is full, or can write something to the file system.
du: Querying disk usage space for a file or folder
If you have a lot of files and folders under the current directory, you can cycle through the space used by all files and folders using the command without the parameter Du. This is not good to see if it is too large, so you have to specify the number of layers in the depth directory, parameter:--max-depth=, this is a very useful parameter! As follows, note that using "*", you can get the space size of the file.
Reminder : Always command more complex than Linux FreeBSD, its du command specifies the depth of the directory layer is more simplified than Linux, the-D.
Here is the code snippet: [Email protected] yayu]# du-h--max-depth=1 work/testing 27M Work/testing/logs 35M work/testing [[email protected] yayu]# du-h--max-depth=1 work/testing/* 8.0K WORK/TESTING/FUNC.PHP 27m work/testing/logs 8.1m work/testing/nohup.out 8.0K WORK/TESTING/TESTING_C.PHP 12k work/testing/ TESTING_FUNC_REG.PHP 8.0k work/testing/testing_get.php 8.0k work/testing/testing_g.php 8.0K work/testing/var.php [Email protected] yayu]# du-h--max-depth=1 work/testing/logs/ 27M work/testing/logs/ [Email protected] yayu]# du-h--max-depth=1 work/testing/logs/* 24K Work/testing/logs/errdate.log_show.log 8.0K Work/testing/logs/pertime_show.log 27M Work/testing/logs/show.log |
It's worth noting that you see an article on the similarities and differences between the Du and DF commands: the du DF difference causes file system false positives to resolve.
Du statistics File size addition
DF Statistics block usage
If a process opens a large file, the large file is dropped directly by RM or MV, then du updates the statistics, DF does not update the statistics, or the space is not released. Until the process of opening the large file was killed.
As a result, if you delete the file below/var/spool/clientmqueue periodically, the space is not released until you kill the process.
After you kill the process using the following command, the system resumes.
Fuser-u/var/spool/clientmqueue
http://www.yayu.org/look.php?id=162
View the size of the Linux file directory and the number of files that the folder contains
Total statistics Size
Du-sh xmldb/
DU-SM * | Sort-n//Statistics current directory size and size sorting
Du-sk * | Sort-n
Du-sk * | grep GUOJF//Look at the size of a person
du-m | Cut-d "/"-F 2//See text before second/character
See how many files are in this folder/*/*/* how many files are there?
Du xmldb/
Du xmldb/*/*/* |wc-l
40752
Explain:
WC [-LMW]
Parameter description:
-L: How many lines
-M: How many characters
-W: how many words
Http://linux.chinaitlab.com/command/734706.html
Linux:ls viewing file sizes in K, M, G units
#man ls
......
-H,--human-readable
Print sizes in human readable format (e.g., 1K 234M 2G)
......
# ls
Cuss.war Nohup.out
# ls-l
Total 30372
-rw-r--r--1 root root 31051909 may 10:07 Cuss.war
-RW-------1 root root 0 Mar 13:52 nohup.out
# LS-LH
Total 30M
-rw-r--r--1 root root 30M may 10:07 Cuss.war
-RW-------1 root root 0 Mar 13:52 nohup.out
# ll-h
Total 30M
-rw-r--r--1 root root 30M may 10:07 Cuss.war
-RW-------1 root root 0 Mar 13:52 nohup.out
Linux commands for viewing file sizes