| DF and Du commands Detailed DF command usage A: displays the disk usage of all file systems and partitions. I: displays the I-nodes usage. K: The size is represented by K (default) T: displays the disk usage of all partitions in a file system. X: displays the disk usage of all partitions of a file system. T: displays the file system name of each partition. Common commands: DF-Hi Du-Sh * view the current directory and file size Operation Details The reference command DF can display the maximum available space and usage of all file systems. See the following example: # DF-H Filesystem size used avail capacity mounted on /Dev/ad0s1a 1.9g 389 m 1.4G 21%/ Devfs 1.0 K 1.0 K 0b 100%/dev /Dev/ad0s1d 989 M 54 K 910 m 0%/tmp /Dev/ad0s1f 4.8g 3.8g 657 M 86%/usr /Dev/ad0s1e 1.9g 149 m 1.6g 8%/var /Dev/ad0s1g 26G 890 K 24g 0%/volume2 /Dev/da0s1d 325g 261g 38g 87%/volume1 The-H parameter is added to indicate that the "human-readable" output is used, that is, the file system uses readable formats such as GB and MB. The first and last fields output by the preceding command are the File System and Its mount point. We can see that the/dev/ad0s1a partition is mounted under the root directory. We mentioned in the previous section that ad represents the IDE hard disk, while S1 represents the first primary sector. I have another SCSI hard disk named Da, which has a large capacity and is mainly used to store data. Devfs is a special file system, which is not a real disk,FreeBSDA Virtual File System used to manage system hardware devices. The following four fields, size, used, avail, and capacity, are the capacity, used size, remaining size, and percentage of the shard. When the hard disk capacity is full, you may see that the percentage used exceeds 100%, becauseFreeBSDSome space will be reserved for the root user so that the root user can still write things to the file system for management when the file system is full. In addition, we can also use parameter-I to view the current inode usage of the file system. Sometimes, although the file system still has space, if there is not enough inode to store the file information, it will not be able to add new files. # DF-ih Filesystem size used avail capacity iused ifree % iused mounted on /Dev/ad0s1a 1.9g 389 m 1.4G 21% 20495 262127/ Devfs 1.0 K 1.0 K 0b 100% 0 0 100%/dev /Dev/ad0s1d 989 M 62 k 910 m 0% 24 141286 0%/tmp /Dev/ad0s1f 4.8g 3.8g 657 M 86% 311439 348015/usr /Dev/ad0s1e 1.9g 149 m 1.6g 8% 1758 280864/var /Dev/ad0s1g 26G 890 K 24g 0% 12 3532786 0%/volume2 /Dev/da0s1d 325g 261g 38g 87% 707277 43311409/volume1 We can see that the number of inode used in the root directory is 20495, and there are 262127 available inode. Tips Do you still remember what inode is? Inode is the basic information (metadata) used to store archives and directories, including the time, file name, user, and group. When dividing a sector, the system will first make a bunch of inode for later use. The number of inode is related to the total number of files and directories that can be created in the system. If most of the files to be stored are small, there will be a large number of files on hard disks of the same size, that is, a large number of inode are required to mount files and directories. Du: Query the disk space used by an archive or directory A: displays the disk space occupied by all directories and each file in the second directory. B: The size is represented by bytes (the default value is K bytes) C: add the total value (default) S: only display the total size of each file X: only calculate the files of the same file system. L: Calculate the size of all files Common commands:Du- Operation DetailsReference CommandDuThe disk space occupied by all files in each directory is displayed in subdirectories of the specified directory. For example: #Du-H/etc 104 K/etc/defaults 6.0 K/etc/X11 8.0 K/etc/Bluetooth 4.0 K/etc/gnats 52 K/etc/ISDN 388 K/etc/mail 68 K/etc/mtree 2.0 k/etc/NTP 38 K/etc/PAM. d 44 K/etc/periodic/daily 6.0 K/etc/periodic/monthly 42 k/etc/periodic/security 16 K/etc/periodic/weekly 110 K/etc/periodic 6.0 K/etc/PPP 318 K/etc/rc. d 2.0 k/etc/skel 130 K/etc/ssh 10 K/etc/SSL 1.7 m/etc The-H parameter is used to display the human-readable format. We can useDuThis command is used to check which directory occupies the most space. However,DuThe output result of is usually very long. We can add the-S parameter to omit the subdirectories in the specified directory, and only display the total sum of the directories: #Du-SH/etc 1.7 m/etc When viewing the usage of the Directory, we can export the output results to the sort command for sorting to know which file has used the most space: #Du/Etc | sort-Nr | more 1746/etc 388/etc/mail 318/etc/rc. d 130/etc/ssh 110/etc/periodic 104/etc/defaults 68/etc/mtree 52/etc/ISDN 44/etc/periodic/daily 42/etc/periodic/security 38/etc/PAM. d 16/etc/periodic/weekly 10/etc/SSL 8/etc/Bluetooth 6/etc/PPP 6/etc/periodic/monthly 6/etc/X11 4/etc/gnats 2/etc/skel 2/etc/NTP The-Nr parameter of sort indicates that reverse sorting is performed by numerical sorting. Because we want to sort the directory size, we cannot use the size output of human-readable, otherwise, the directory size may contain letters such as K and M, which may result in incorrect sorting. |