free 命令用于查看系统内存状态。包括物理内存、虚拟内存、共享内存和系统缓存等。
-h 已人类可读的方式显示内存的使用情况。
[root@cenos79 log]# free -h
total used free shared buff/cache available
Mem: 1.8G 338M 93M 15M 1.4G 1.3G
Swap: 1.0G 235M 789M
备注:
1、total: 内存总量
2、used: 已使用的内存数量
3、free: ?
4、shared:进程共享的内存数量
5、buff/cache ?
6、available 可用的内存
默认情况展示
[root@cenos79 log]# free
total used free shared buff/cache available
Mem: 1882232 346684 95452 16108 1440096 1331964
Swap: 1049596 240896 808700
-b 已 byte 为单位显示内存的使用情况。
[root@cenos79 log]# free -b
total used free shared buff/cache available
Mem: 1927405568 354955264 97787904 16494592 1474662400 1363980288
Swap: 1074786304 246677504 828108800
[root@cenos79 log]#
-k 已 kb 为单位显示内存的使用情况。
[root@cenos79 log]# free -k
total used free shared buff/cache available
Mem: 1882232 346684 95460 16108 1440088 1331964
Swap: 1049596 240896 808700
-m 已 mb 为单位显示内存的使用情况。
[root@cenos79 log]# free -m
total used free shared buff/cache available
Mem: 1838 338 93 15 1406 1300
Swap: 1024 235 789
-t 显示内存总和列。
[root@cenos79 log]# free -t
total used free shared buff/cache available
Mem: 1882232 346804 95336 16108 1440092 1331844
Swap: 1049596 240896 808700
Total: 2931828 587700 904036 -- -t 选项显示出总和列
[root@cenos79 log]#
-s<间隔秒数> 根据指定的间隔秒数持续显示内存的情况。
[root@cenos79 log]# free -h -s 5 ## 没隔5s 显示一次内存使用情况
total used free shared buff/cache available
Mem: 1.8G 338M 93M 15M 1.4G 1.3G
Swap: 1.0G 235M 789M
total used free shared buff/cache available
Mem: 1.8G 338M 92M 15M 1.4G 1.3G
Swap: 1.0G 235M 789M