Centos7 free命令详解


前言

centos7 free 命令详解。
查看centos7服务内存使用情况。

本文内容默认使用free -h人类可读的方式进行展示


一、如何使用

命令为 free [options]

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.0G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

total 表示总计物理内存的大小
used 表示已使用内存大小
free 表示空余内存大小
shared 表示共享内存大小
buff/cache 表示磁盘缓存大小(来源于网上)
available 表示可用分配的物理内存大小
swap 交换区总量
我一般只关注total used free available 这四项。total是否=used+available 未做验证

centos官网查了查,没找到具体命令详细信息。 如果有人找到欢迎分享给我
free --help 查看所有操作。

[root@localhost ~]# free --help

Usage:
 free [options]

Options:
 -b, --bytes         show output in bytes #以字节显示输出
 -k, --kilo          show output in kilobytes #以千字节显示输出
 -m, --mega          show output in megabytes #以兆字节显示输出
 -g, --giga          show output in gigabytes #以千兆字节显示输出
     --tera          show output in terabytes #以TB 为单位显示输出
     --peta          show output in petabytes #以PB 为单位显示输出
 -h, --human         show human-readable output #显示人类可读的输出
     --si            use powers of 1000 not 1024 #使用 1000 而不是 1024 的幂
 -l, --lohi          show detailed low and high memory statistics #显示详细的低和高内存统计信息
 -t, --total         show total for RAM + swap #显示 RAM + 交换的总数
 -s N, --seconds N   repeat printing every N seconds #每 N 秒重复打印一次
 -c N, --count N     repeat printing N times, then exit #重复打印N次,然后退出
 -w, --wide          wide output #宽输出 就是将buff/cache分开展示为buffers和cache

     --help     display this help and exit
 -V, --version  output version information and exit

For more details see free(1).

二、示例

1.查看详情

代码如下(示例):

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.0G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

# -w 宽输出 就是将buff/cache分开为buffers和cache
[root@localhost ~]# free -hw
              total        used        free      shared     buffers       cache   available
Mem:           5.7G        2.0G        2.9G         11M        2.0M        790M        3.4G
Swap:          2.0G          0B        2.0G

2.循环打印

代码如下(示例):

[root@localhost ~]# free -h -s 3
              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.0G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.0G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.0G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

^C
[root@localhost ~]# 

3.打印N次并退出

打印3次并退出 代码如下(示例):

[root@localhost ~]# free -hc 3
              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.1G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.1G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G

              total        used        free      shared  buff/cache   available
Mem:           5.7G        2.1G        2.9G         11M        792M        3.4G
Swap:          2.0G          0B        2.0G
[root@localhost ~]# 

总结

以上就是今天要讲的内容,本文仅仅简单介绍了free的使用,而centos提供了大量命令,可自行度娘或google 。
有朋友找到centos官方的命令文档,希望可以分享给我,谢谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值