View file and folder size under Linux

  

When the disk size exceeds the standard, there will be an alarm prompt. If you master the df and du commands, it is a very wise choice.

df can view the size of the first-level folder, the proportion of use, the file system and its point of entry, but can't do anything about the file. Du can view the size of files and folders.

The two are used together and are very effective. For example, use df to see which level of the directory is too large, and then use df to view the size of the folder or file, so you can quickly determine the crux.

The following is a brief introduction to the

df command to display the available space and usage of all current file systems. Please see the following example: The following is the code snippet: [yusky@hupohost ~]# df - hFilesystem Size Used Avail Use% Mounted on/dev/vda1 20G 2.6G 17G 14% /tmpfs 972M 0 972M 0% /dev/shm[yusky@hupohost ~]#

Parameter -h means "Human- The output of readable" is the easy-to-read format of GB, MB, etc. in the file system size.

The first field (Filesystem) and the last field (Mounted on) of the above command output are the file system and its mount point. We can see that the partition /dev/sda1 is hung in the root directory.

The next four fields Size, Used, Avail, and Use% are the partition's capacity, used size, remaining size, and percentage used. Under FreeBSD, when the hard disk capacity is full, you may see that the percentage used has exceeded 100%, because FreeBSD will leave some space for root, so that when the file system is full, you can still write things to the file system. For management.

du: Query disk usage space of files or folders

If there are many files and folders in the current directory, use the command without parameter du to cycle through all files and folders. The space used. This is not good for viewing where the place is too large, so you have to specify the number of layers in the deep directory, the parameter: – max-depth=, this is an extremely useful parameter! As follows, pay attention to the use of “*”, you can get the size of the file space.

Reminder: The command has always been more complicated than Linux FreeBSD, its du command specifies the number of layers in the deep directory is simplified than Linux. For -d

The following is the code snippet: [yusky@hupohost ~]# du -h --max-depth=1 /home/wwwroot10M /home/wwwroot/domains.com10M /home/wwwroot/domains2. com20M /home/wwwroot/domains3.com40M /home/wwwroot[yusky@hupohost ~]#

du stat file size plus df stats usage

If there is a process open When a large file is used, this large file is directly dropped by rm or mv, then du will update the statistics, df will not update the statistics, or think that the space is not released. Until this process of opening a large file is killed by Kill.

This way, when the files under /var/spool/clientmqueue are deleted regularly, if the process is not killed, the space is not released.

After killing the process with the following command, the system is restored. Fuser -u /var/spool/clientmqueue


View the size of the linux file directory and the total number of files in the folder.

du -sh xmldb/du - Sm * |  Sort -n //statistics current directory size and size size sort du -sk * |  Sort -ndu -sk * |  Grep guojf //See the size of a person du -m |  Cut -d "/" -f 2 //See the text before the second /character

See how many files in this folder/*/*/* How many files du xmldb/du xmldb/*/*/* | Wc -l40752 Explanation: wc [-lmw]

Parameter Description: -l : How many lines -m : How many characters -w : How many words


Linux:ls K, M, G for the unit view file size #man ls……-h, --human-readableprint sizes in human readable format (eg, 1K 234M 2G)……# lscuss.war nohup.out# ls - Ltotal 30372-rw-r--r-- 1 root root 31051909 May 24 10:07 cuss.war-rw------- 1 root root 0 Mar 20 13:52 nohup.out# ls -lhtotal 30M- Rw-r--r-- 1 root root 30M May 24 10:07 cuss.war-rw------- 1 root root 0 Mar 20 13:52 nohup.out# ll -htotal 30M-rw-r --r-- 1 root root 30M May 24 10:07 cuss.war-rw------- 1 root root 0 Mar 20 13:52 nohup.out

Copyright © Windows knowledge All Rights Reserved