free

free 命令显示可用和已用物理内存和交换内存。

-b、-k、-m、-g 选项分别以 bytes、KB、MB、GB 为单位显示输出

free -b
               total        used        free      shared  buff/cache   available
Mem:      1861107712   500932608   864264192    33566720   701353984  1360175104
Swap:     4227854336           0  4227854336

free -k
               total        used        free      shared  buff/cache   available
Mem:         1817488      489176      844008       32780      684932     1328312
Swap:        4128764           0     4128764

free -m
               total        used        free      shared  buff/cache   available
Mem:            1774         477         824          32         668        1297
Swap:           4031           0        4031

free -g
               total        used        free      shared  buff/cache   available
Mem:               1           0           0           0           0           1
Swap:              3

total ≈ used + free + buff/cache

-s 选项指定刷新的时间间隔

如果 buff/cache 和 available 值较低,说明内存不足,如果 available 值大于 20% 说明内存充足。

Last updated