free
进程与系统
用法
free -h在 Linux 上统计还剩多少内存和交换区;该看的一列是 available 而不是 free,因为缓存需要时会还回来,而 macOS 根本没有 free(用 vm_stat)。
常用选项
| 选项 | 含义 |
|---|---|
| -h | Human units, so Gi and Mi instead of raw kibibytes. |
| -m / -g | Force mebibytes / gibibytes. |
| -s 5 | Repeat every five seconds until Ctrl+C. |
| -t | Add a total row for RAM plus swap. |
| -w | Wide output that separates buffers from cache. |
示例
free -hRead the available column: that is what a new program can actually get.
free -m -s 5Watch memory every five seconds while a job runs.
看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. free 是做什么的?
在 Linux 上统计还剩多少内存和交换区;该看的一列是 available 而不是 free,因为缓存需要时会还回来,而 macOS 根本没有 free(用 vm_stat)。
Q. 怎么写?
free -h —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 5 个,完整列表在 man free。这条命令属于进程与系统。
相关命令
man 手册: man free