View file size

巴扎黑
Release: 2023-03-02 16:38:01
Original
1738 people have browsed it

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

df can view the first-level folder size, usage ratio, file system and its mount point, but it can do nothing about files.
You can check the size of files and folders with du.

The two are used together and are very effective. For example, use df to check which first-level directory is too large, and then use df to check the size of the folder or file, so that the crux can be quickly determined.

The following is a brief introduction

The df command can display the available space and usage of all file systems currently. Please see the following example:

The following is a code snippet:

[yayug@yayu ~]$ 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.8 G 218M 7.2G 3% /var
/dev/sda5 7.8G 166M 7.2G 3% /tmp
/dev/sda3 9.7G 2.5G 6.8G 27% /usr
tmp fs 2.0G 0 2.0G 0% /dev/shm

The parameter -h indicates using "Human-readable" output, that is, using easy-to-read formats such as GB and MB in the file system size.

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

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

du: Query the disk space used by files or folders

If there are many files and folders in the current directory, use the command without parameter du to list the space used by all files and folders in a loop. This is not good for checking which area is too large, so you have to specify the number of layers deep into the directory. Parameter: --max-depth=, this is an extremely useful parameter! As shown below, pay attention to the use of "*" to get the usage space of the file.

Reminder: FreeBSD has always had more complex commands than Linux, but its du command specifies the number of layers deep into the directory is simpler than Linux, which is -d.

The following is the code snippet:

[root@bsso yayu]# du -h --max-depth=1 work/testing
27M work/testing/logs
35M work/testing

[root@bsso 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

[root@bsso yayu]# du -h --max-depth=1 work/testing/logs/
27M work/testing/logs/

[root@bsso 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 is worth noting that I saw a command for du and df Similar and different articles: "Du df differences lead to file system false alarm resolution".

du statistics file size summation
df statistics data block usage

If a process opens a large file and the large file is directly deleted by rm or mv, du will update the statistical value, but df will not update the statistical value, and it will still be considered that the space has not been released. Until the process that opens the large file is killed.

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

Use the following command to kill the process and the system will recover.
fuser -u /var/spool/clientmqueue

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!