This article transferred from: http://www.cnblogs.com/benio/archive/2010/10/13/1849946.html
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 Du to view the folder or file size, 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 drive is full, you may
You will see that the percentage used is more than 100%, because FreeBSD will leave some space for root, so that when the file system is full, root can write things to the file system for management.
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. It's not good to see if that place is too big, so you have to specify
The number of layers in the directory, parameters:--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 The current directory size and an Ann size sort, in m units
Du-sk * | Sort-n
See how many files (not including folders) are in this folder Xmldb
Du xmldb/
/*/*/* How many files are there?
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
# 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
View file and folder sizes under Linux