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
View file and folder sizes under Linux