Heim  >  Artikel  >  System-Tutorial  >  12 nützliche df-Befehle zum Überprüfen des Speicherplatzes unter Linux

12 nützliche df-Befehle zum Überprüfen des Speicherplatzes unter Linux

PHPz
PHPznach vorne
2024-02-12 14:30:101211Durchsuche

1. Überprüfen Sie die Speicherplatznutzung im Dateisystem

Dieser df Befehl zeigt den Gerätenamen, die Gesamtblockanzahl, den gesamten Festplattenspeicher, den belegten Festplattenspeicher, den freien Festplattenspeicher und Informationen zum Bereitstellungspunkt im Dateisystem an.

linux 中检查磁盘空间的 12 个有用的 df 命令

[root@local ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23185840  51130588  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

2. Informationen zur Speicherplatznutzung aller Dateisysteme anzeigen

Wie oben, aber es werden auch Informationen zu virtuellen Dateisystemen und zur gesamten Dateisystem-Festplattennutzung sowie deren Speichernutzung angezeigt.

[root@local ~]# df -a

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23186116  51130312  32% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs

3. Zeigen Sie die Speicherplatznutzung in einem für Menschen lesbaren Format an

Ist Ihnen aufgefallen, dass der obige Befehl Informationen in Bytes anzeigt, die überhaupt nicht lesbar sind, da wir es gewohnt sind, Größen in Megabyte, Gigabyte usw. abzulesen, was leicht zu verstehen und zu merken ist.

Dieser df命令提供了一个选项来显示尺寸Human Readable格式通过使用'-h'(以人类可读的格式打印结果(例如,1K 2M 3G Befehl bietet eine Option zum Anzeigen von AbmessungenMenschenlesbares-Format unter Verwendung von '-h' (Drucken Sie das Ergebnis in einem für Menschen lesbaren Format aus (z. B. 1K 2M 3G)).

[root@local ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p2      75G   23G   49G  32% /
/dev/cciss/c0d0p5      24G   22G  1.2G  95% /home
/dev/cciss/c0d0p3      29G   25G  2.6G  91% /data
/dev/cciss/c0d0p1     289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm

4. Informationen zum /home-Dateisystem anzeigen

Informationen zu einem einzelnen Gerät anzeigen /home Dateisystem im für Menschen lesbaren Format mit dem folgenden Befehl.

[root@local ~]# df -hT /home

Filesystem  Type    Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p5 ext3     24G   22G  1.2G  95% /home

5. Dateisysteminformationen in Bytes anzeigen

Zeigt alle Dateisysteminformationen und -nutzung 1024-byte块,使用选项’-k‘(例如--block-size=1K) unten.

[root@local ~]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23187212  51129216  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

6. Dateisysteminformationen in MB-Einheiten anzeigen

Zeigt alle Informationen zur Dateisystemnutzung anMB(Mega Byte) 将该选项用作 -m.

[root@local ~]# df -m

Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2        76525     22644     49931  32% /
/dev/cciss/c0d0p5        24217     21752      1215  95% /home
/dev/cciss/c0d0p3        29057     24907      2651  91% /data
/dev/cciss/c0d0p1          289        22       253   8% /boot
tmpfs                      252         0       252   0% /dev/shm

7. 以 GB 为单位显示文件系统信息

显示所有文件系统统计信息GB(Gigabyte) 将该选项用作 ‘df -h‘。

[root@local ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p2      75G   23G   49G  32% /
/dev/cciss/c0d0p5      24G   22G  1.2G  95% /home
/dev/cciss/c0d0p3      29G   25G  2.6G  91% /data
/dev/cciss/c0d0p1     289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm

8. 显示文件系统 inode

使用 -i开关将显示文件系统的已使用 inode 数量及其百分比信息。

[root@local ~]# df -i

Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/cciss/c0d0p2    20230848  133143 20097705    1% /
/dev/cciss/c0d0p5    6403712  798613 5605099   13% /home
/dev/cciss/c0d0p3    7685440 1388241 6297199   19% /data
/dev/cciss/c0d0p1      76304      40   76264    1% /boot
tmpfs                  64369       1   64368    1% /dev/shm

9. 显示文件系统类型

如果您注意到上述所有命令输出,您将看到结果中没有提到Linux 文件系统类型。要检查系统的文件系统类型,请使用选项 T。它将显示文件系统类型以及其他信息。

[root@local ~]# df -T

Filesystem  Type   1K-blocks  Used      Available Use% Mounted on
/dev/cciss/c0d0p2 ext3    78361192  23188812  51127616  32%   /
/dev/cciss/c0d0p5 ext3    24797380  22273432  1243972   95%   /home
/dev/cciss/c0d0p3 ext3    29753588  25503792  2713984   91%   /data
/dev/cciss/c0d0p1 ext3    295561     21531    258770    8%    /boot
tmpfs   tmpfs   257476         0    257476    0%   /dev/shm

10. 包括某些文件系统类型

如果要显示某些文件系统类型,请使用 -t 选项。例如下面的命令只会显示ext3文件系统。

[root@local ~]# df -t ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23190072  51126356  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot

11. 排除某些文件系统类型

如果要显示不属于的文件系统类型ext3键入使用选项作为 -x。例如,以下命令将只显示除ext3.

[root@local ~]# df -x ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   257476         0    257476   0% /dev/shm

12. 显示 df 命令的信息。

使用'--help‘ 开关将显示与df命令。

[root@local ~]# df --help

Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all             include dummy file systems
  -B, --block-size=SIZE use SIZE-byte blocks
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

Report bugs to .

Das obige ist der detaillierte Inhalt von12 nützliche df-Befehle zum Überprüfen des Speicherplatzes unter Linux. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:lxlinux.net. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen