Linux命令——free

参考:10 ‘free’ Commands to Check Memory Usage in Linux

简介

free 命令查看物理内存(physical memory)、交换内存(swap memory)和内核缓冲区内存(buffers used by kernel in Linux/Unix)使用情况。

用法

无参数

[root@localhost ~]# free
              total        used        free      shared  buff/cache   available
Mem:        8157208      326528     7175756       11856      654924     7517932
Swap:       4063228           0     4063228
View Code

默认输出,单位是KB,你也可以显式使用-k参数指定。当然-b使用Byte单位,-m使用MB单位,-g使用GB

但是这些单位,会影响所有数据,还是不够人性化。-h显示更人性化,输出你可以看到KB、MB、GB等单位

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           7.8G        318M        6.8G         11M        639M        7.2G
Swap:          3.9G          0B        3.9G
View Code

定时定次输出

-s参数可以设置定时输出(每隔多久输出),默认值是1s

-c参数可以设置定次输出,累计输出多少次退出

free -s 2 -c 5

每隔2s输出一次,共输出5次

              total        used        free      shared  buff/cache   available
Mem:        8157208      326792     7175380       11856      655036     7517672
Swap:       4063228           0     4063228

              total        used        free      shared  buff/cache   available
Mem:        8157208      326792     7175380       11856      655036     7517672
Swap:       4063228           0     4063228

              total        used        free      shared  buff/cache   available
Mem:        8157208      326792     7175380       11856      655036     7517672
Swap:       4063228           0     4063228

              total        used        free      shared  buff/cache   available
Mem:        8157208      326840     7175332       11856      655036     7517624
Swap:       4063228           0     4063228

              total        used        free      shared  buff/cache   available
Mem:        8157208      326824     7175348       11856      655036     7517640
Swap:       4063228           0     4063228
View Code

额外备注

free输出,关于仔细看的会发现内存比实际物理内存容量小。其原因是free命令显示的总内存是除去内核文件占用内存和一些系统保留的内存之后能使用的内存

使用dmesg查看内存,获得的内存信息基本上就是真实物理内存大小了。

 

 

 

转载于:https://www.cnblogs.com/kelamoyujuzhen/p/9941114.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值