Linux常用命令-free

命令

free

描述

Display amount of free and used memory in the system
查看系统内存使用率

用法

1
free [options]

选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Options:
-b, --bytes 单位bytes
-k, --kilo 单位kilobytes
-m, --mega 单位megabytes
-g, --giga 单位gigabytes
--tera 单位terabytes
--peta 单位petabytes
-h, --human 以可读形式显示
--si 单位进制使用1000,默认为1024
-l, --lohi 显示最高和最低内存使用大小
-t, --total 汇总信息
-s N, --seconds N 指定刷新时间,秒
-c N, --count N 指定刷新次数
-w, --wide 对齐标题显示

used大小=total-free-buffers-cache

注意

free命令读取的是/proc/meminfo文件

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ free
total used free shared buff/cache available
Mem: 2027896 174220 1465804 9676 387872 1697392
Swap: 2097148 0 2097148
$ free -b
total used free shared buff/cache available
Mem: 2076565504 178696192 1500680192 9908224 397189120 1737834496
Swap: 2147479552 0 2147479552
$ free -k
total used free shared buff/cache available
Mem: 2027896 174224 1465792 9676 387880 1697388
Swap: 2097148 0 2097148
$ free -m
total used free shared buff/cache available
Mem: 1980 170 1431 9 378 1657
Swap: 2047 0 2047
$ free -h
total used free shared buff/cache available
Mem: 1.9G 170M 1.4G 9.4M 378M 1.6G
Swap: 2.0G 0B 2.0G
$ free -l
total used free shared buff/cache available
Mem: 2027896 174388 1465628 9676 387880 1697224
Low: 2027896 562268 1465628
High: 0 0 0
Swap: 2097148 0 2097148
$ free --si -h
total used free shared buff/cache available
Mem: 2.0G 174M 1.5G 9.7M 387M 1.7G
Swap: 2.1G 0B 2.1G
$ free -mw
total used free shared buffers cache available
Mem: 1980 170 1431 9 2 376 1657
Swap: 2047 0 2047
$ free -mt
total used free shared buff/cache available
Mem: 1980 170 1431 9 378 1657
Swap: 2047 0 2047
Total: 4028 170 3479