命令簡介
linux下可以使用free
命令看到系統實際使用內存的情況,一般用free -h
命令查看內存佔用情況。而系統實際可用內存是不是free部分呢,不是的,系統實際內存佔用以及可用內存有如下幾個加減法:
- 內存佔用:used - buffers - cached
- 可用內存:buffers + cached + free
命令選項
- -b:以Byte爲單位顯示內存使用情況
- -k:以KB爲單位顯示內存使用情況
- -m:以MB爲單位顯示內存使用情況
- -h:以人類更容易理解方式進行展示
- -t:顯示內存總和信息
- -s <間隔秒數>:持續觀察內存使用狀況
常用命令
free -h
查看內存使用情況
[devl@xungen ~]$ free -h
total used free shared buff/cache available
Mem: 992M 210M 68M 200K 713M 580M
Swap: 1.0G 137M 886M
Mem
行是物理內存使用情況Swap
行是虛擬內存作用情況used
列爲已分配內存free
列爲未分配的內存total
列爲物理內存總量shared
列爲共享內存available
列爲可用內存
free -h
查看內存與使用情況與內存總和
[devl@xungen ~]$ free -ht
total used free shared buff/cache available
Mem: 992M 216M 73M 264K 702M 574M
Swap: 1.0G 137M 886M
Total: 2.0G 354M 959M
Mem
行是物理內存使用情況Swap
行是虛擬內存作用情況Total
行爲各項內存總和信息
free -h -s 1
每隔一秒鐘打印一次內存使用信息
[devl@xungen ~]$ free -h -s 1
total used free shared buff/cache available
Mem: 992M 216M 75M 264K 700M 574M
Swap: 1.0G 137M 886M
total used free shared buff/cache available
Mem: 992M 216M 75M 264K 700M 573M
Swap: 1.0G 137M 886M
total used free shared buff/cache available
Mem: 992M 216M 75M 264K 700M 573M
Swap: 1.0G 137M 886M
total used free shared buff/cache available
Mem: 992M 216M 75M 264K 700M 574M
Swap: 1.0G 137M 886M