free -h
free命令输出列的含义
free命令手册
free选项
free -b以Byte为单位显示内存使用情况
free -k以KB为单位显示内存使用情况
free -m以MB为单位显示内存使用情况
free -g以GB为单位显示内存使用情况
free -h以人类友好方式显示内存使用情况
free -w
free -t以总和的形式查询内存的使用信息
free -s 秒数:周期性的查询内存使用信息
free -s 间隔秒数 -c 执行次数:周期性执行free并统计次数
参考资料
free命令:了解内存使用情况
1 | [root@localhost ~]# free |
默认的free命令输出的单位是KB.
free -h
1 | [root@localhost ~]# free -h |
这里空闲内存free只有44MB,这点内存好像不够用了。实际上是因为Linux为提高效率,利用程序暂时不用的内存,缓冲读写过的磁盘信息。
从上面的输出结果可以看出,当前有2587176KB的缓冲内存buffer/cache,不计buffer/cache的话,系统的实际可用内存available为2605751KB,远不止free的44MB。
free命令输出列的含义
free命令输出的列 | 含义 |
---|---|
total | 总内存 |
used | 已使用的内存 |
free | 空闲内存 |
buff/cache | 缓存内存 |
available | 实际可用内存 |
free命令手册
1 | FREE(1) User Commands FREE(1) |
free选项
1 | [root@localhost ~]# free --help |
-b 以Byte为单位显示内存使用情况。
-k 以KB为单位显示内存使用情况。
-m 以MB为单位显示内存使用情况。
-h 以合适的单位显示内存使用情况,最大为三位数,自动计算对应的单位值。单位有:
B = bytes
K = kilos
M = megas
G = gigas
T = teras
-s<间隔秒数> 持续观察内存使用状况。
-c<重复次数>
-t 显示内存总和列。
-V 显示版本信息。
free -b以Byte为单位显示内存使用情况
1 | [root@localhost ~]# free -b |
free -k以KB为单位显示内存使用情况
1 | [root@localhost ~]# free -k |
free -m以MB为单位显示内存使用情况
1 | [root@localhost ~]# free -m |
free -g以GB为单位显示内存使用情况
1 | [root@localhost ~]# free -g |
free -h以人类友好方式显示内存使用情况
1 | [root@localhost ~]# free -h |
free -w
1 | [root@localhost ~]# free -w |
free -t以总和的形式查询内存的使用信息
1 | [root@localhost ~]# free -t |
free -s 秒数:周期性的查询内存使用信息
free -s 10
表示每隔10秒执行一次free命令。1
2
3
4
5
6
7
8
9
10
11
12
13
14[root@localhost ~]# free -s 10
total used free shared buff/cache available
Mem: 3686064 1080672 56516 1508 2548876 2574103
Swap: 0 0 0
total used free shared buff/cache available
Mem: 3686064 1072048 65064 1508 2548952 2582727
Swap: 0 0 0
total used free shared buff/cache available
Mem: 3686064 1077880 59172 1508 2549012 2576895
Swap: 0 0 0
......
free -s 间隔秒数 -c 执行次数:周期性执行free并统计次数
1 | -s N, --seconds N repeat printing every N seconds |
命令free -s 5 -c 3
表示每隔5秒执行一次free命令,并重复执行3次。
运行结果:1
2
3
4
5
6
7
8
9
10
11
12
13[root@localhost ~]# free -s 5 -c 3
total used free shared buff/cache available
Mem: 3686064 1084308 51740 1508 2550016 2570467
Swap: 0 0 0
total used free shared buff/cache available
Mem: 3686064 1082564 53464 1508 2550036 2572211
Swap: 0 0 0
total used free shared buff/cache available
Mem: 3686064 1080316 55648 1508 2550100 2574459
Swap: 0 0 0
[root@localhost ~]#