free
rose1 发表于 2020-09-18 09:02浏览次数:
在类似Unix的操作系统上,free命令显示可用内存和已用物理内存和交换内存的总量,以及内核使用的缓冲区。
本文档介绍了免费的GNU / Linux版本。
On Unix-like operating systems, the free command displays the total amount of free and used physical and swap memory, and the buffers used by the kernel.
This document describes the GNU/Linux version of free.
目录:
1 free 运行系统环境
2 free 语法
3 free 例子
free 运行系统环境
free 语法
free [options]
选件
-b, --bytes
|
显示内存量(以字节为单位)。
|
-k, --kilo
|
显示内存量(以千字节为单位)。这是默认值。
|
-m, --mega
|
显示内存量(以兆字节为单位)。
|
-g, --giga
|
以GB为单位显示内存量。
|
--tera
|
显示以TB为单位的内存量。
|
-h, --human
|
显示所有输出字段自动缩放为最短的三位数单位并显示打印输出的单位。使用以下单位。
B = bytes
K = kilos
M = megas
G = gigas
T = teras
如果您有1PB的RAM或交换空间,则数字以TB为单位,并且您的计算机很棒。
|
-c, --countcount
|
显示结果计数时间。需要-s选项。
|
-l, --lohi
|
显示详细的低内存和高内存统计信息。
|
-o, --old
|
以旧格式显示输出;唯一的不同是此选项将禁用“缓冲区调整”行的显示。
|
-s, --secondsseconds
|
连续不断地显示结果延迟秒数。您实际上可以指定任何浮点数来进行延迟。该usleep系统调用用于微秒级的延迟时间。
|
--si
|
使用1000的幂而不是1024。
|
-t, --total
|
显示一行以显示列总计。
|
--help
|
打印帮助。
|
-V, --version
|
显示版本信息。
|
free [options]
Options
-b, --bytes
|
Display the amount of memory in bytes.
|
-k, --kilo
|
Display the amount of memory in kilobytes. This is the default.
|
-m, --mega
|
Display the amount of memory in megabytes.
|
-g, --giga
|
Display the amount of memory in gigabytes.
|
--tera
|
Display the amount of memory in terabytes.
|
-h, --human
|
Show all output fields automatically scaled to shortest three digit unit and display the units of print out. Following units are used.
B = bytes
K = kilos
M = megas
G = gigas
T = teras
If you have a petabyte of RAM or swap, the number is in terabytes and your computer is awesome.
|
-c, --countcount
|
Display the result count times. Requires the -s option.
|
-l, --lohi
|
Show detailed low and high memory statistics.
|
-o, --old
|
Display the output in old format; the only difference being this option will disable the display of the "buffer adjusted" line.
|
-s, --secondsseconds
|
Continuously display the result delay seconds apart. You may actually specify any floating point number for delay. The usleep system call is used for microsecond resolution delay times.
|
--si
|
Use power of 1000 not 1024.
|
-t, --total
|
Display a line showing the column totals.
|
--help
|
Print help.
|
-V, --version
|
Display version information.
|
free 例子
free
不加选择地free运行会显示类似于以下示例的图表。
total used free shared buffers cached
Mem: 1006708 935872 70836 0 148244 346656
-/+ buffers/cache: 440972 565736
Swap: 262140 130084 132056
Tip
使用free命令时,两个重要的行是-/ + buffers / cache行和Swap行。如果您想对可用的可用内存有个好主意,则应该阅读缓冲区/缓存中的可用部分。Linux将内存中的内容保留在缓冲区中,以帮助不得不从较慢的磁盘驱动器一遍又一遍地访问相同的数据。如果缓冲区/高速缓存的可用内存不足或交换可用空间不足,则必须升级内存。
free -ms 5
上面的命令以兆字节显示内存,并带有“ s 5 ”,告诉系统连续轮询数据并显示结果。
watch free
该命令与上述命令相似,并使用watch来显示当前的内存使用情况。
free
Running free with no options displays a chart similar to the example below.
total used free shared buffers cached
Mem: 1006708 935872 70836 0 148244 346656
-/+ buffers/cache: 440972 565736
Swap: 262140 130084 132056
Tip
When using the free command the two important lines are the -/+ buffers/cache line and Swap line. If you're wanting to get a good idea on how much free memory is available, the free section in the buffers/cache is what you should be reading. Linux will keep the contents of memory in the buffers to help having to access the same data over-and-over from the slower disk drive. If your buffers/cache free memory is low or your swap free is low a memory upgrade is necessary.
free -ms 5
The above command displays the memory in megabytes with the "s 5" telling the system to continuously poll the data and display the results.
watch free
This command is similar to the command mentioned above and uses watch to display the current memory usage.