When the disk size exceeds the standard there will be alarm prompts, then if Master df and du command is very wise choice.
DF can view the level of folder size, usage ratio, file system, and its mount points, but it does nothing for the file.
Du can view the size of files and folders.
They work together and are very effective. For example, use DF to see which level of directory is too large, and then use DF to view the size of folders or files, so you can quickly determine the crux.
The following is a brief introduction to each
The DF command can show the available space and usage for all current file systems, and see the following example
The code is as follows |
Copy Code |
[Yusky@hupohost ~]# Df-h FileSystem Size Used Avail use% mounted on /DEV/VDA1 20G 2.6G 17G 14%/ Tmpfs 972M 0 972M 0%/dev/shm [Yusky@hupohost ~]#
|
Parameter-H indicates the use of "human-readable" output, that is, in the file system size using GB, MB, and other readable format.
The first field (filesystem) and the last field (mounted on) of the command output above are the file system and its mount point respectively. We can see/dev/sda1 this partition is hanging in the root directory.
The next four fields size, Used, avail, and use% are the capacity of the partition, the size used, the remaining size, and the percentage used. FreeBSD, when the hard drive is full, you may see that the percentage used is over 100%, because FreeBSD will leave some room for root, so that root can be written to the file system when the file system is full, for management.
du: Querying disk usage for files or folders
If you have a lot of files and folders in the current directory, you can iterate through the space used by all files and folders by using commands with no parameters du. This is a bad place to see if it's too big, so specify the number of layers in the Drill-down directory, Parameters: –max-depth=, which is a very useful parameter! For example, note that you can use "*" to get the size of the file space.
Reminder: Always command a more complex FreeBSD than Linux, its du command specifies the number of layers in the Drill-down directory is simpler than Linux-D
The code is as follows |
Copy Code |
[Yusky@hupohost ~]# du-h--max-depth=1/home/wwwroot 10m/home/wwwroot/domains.com 10m/home/wwwroot/domains2.com 20m/home/wwwroot/domains3.com 40m/home/wwwroot [Yusky@hupohost ~]#
|
If there is a process opening a large file, the large file is directly out of RM or MV, then du will update the statistics, DF will not update the statistics, or think the space is not released. Until the process of opening a large file is killed.
This way, when the files below/var/spool/clientmqueue are deleted regularly, the space is not released unless the process is killed.
The system recovers after the process is killed using the following command.
The code is as follows |
Copy Code |
Fuser-u/var/spool/clientmqueue |
View the size of the Linux file directory and the number of files contained in the folder
Total statistics Size
The code is as follows |
Copy Code |
<br> Du-sh xmldb/ DU-SM * | Sort-n//Statistics current directory size and size sort Du-sk * | Sort-n Du-sk * | grep GUOJF//Look at the size of a person du-m | Cut-d "/"-F 2//Look at the text before the second/character <br> See how many files there are in this folder/*/*/* how many files Du xmldb/ Du xmldb/*/*/* |wc-l 40752 <strong> explain:</strong> WC [-LMW] <br> Parameter description: -L: How many lines -M: How many characters -W: how many words |
Linux:ls view file size in K, M, G
code is as follows |
copy code |
#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 ro OT 31051909 may 10:07 Cuss.war -rw------- 1 root root 0 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 p># ll-h Total 30M -rw-r--r-- 1 root 30M could 10:07 Cuss.war -RW------- & nbsp 1 root root 0 13:52 nohup.out |