centos 没有nmtui命令_Linux free 命令
在Linux/Unix 系統(tǒng)上,free是一個(gè)很受系統(tǒng)管理員歡迎的命令,它是一個(gè)功能強(qiáng)大的工具,他能以一種易讀的方式把內(nèi)存使用情況展示出來(lái)
free 展示了系統(tǒng)中空閑和已經(jīng)使用了的物理內(nèi)存、交換內(nèi)存以及內(nèi)核的緩沖區(qū)和頁(yè)面緩存,所有展示的信息都是從 /proc/meminfo 文件解析出來(lái)的
語(yǔ)法
free命令的語(yǔ)法如下
free [options]輸出列說(shuō)明
當(dāng)只輸入free?命令不帶任何選項(xiàng)時(shí),輸出的內(nèi)存和交換內(nèi)存大小是以 KB(kbytes)為單位的,具體的輸出如下所示(在舊版的Linux系統(tǒng)中,顯示可能略有不同):
[root@ecs-centos-7 ~]# freetotal used free shared buff/cache available
Mem: 1881544 325980 1307868 8712 247696 1406892
Swap: 0 0 0
total
總內(nèi)存的大小,可以用于應(yīng)用程序的內(nèi)存
used
已經(jīng)使用內(nèi)存,計(jì)算方式是:used = total - free - buff/cache
free
還沒有使用的內(nèi)存
shared
進(jìn)程之間的共享內(nèi)存
buff/cache
內(nèi)核緩沖區(qū)和頁(yè)面緩存,如果應(yīng)用程序需要的話,可以隨時(shí)回收這部分緩存,通過?free -w?命令可以分別顯示 buff 和 cache 占用的內(nèi)存
available
可用內(nèi)存的預(yù)估大小,可以用于啟動(dòng)新的應(yīng)用程序,實(shí)際應(yīng)用中,可以把 free 和 buff/cache 加起來(lái)看做 available 的近似值,即 free + buff/cache ≈ available
常用的選項(xiàng)
以下是一些常用的選項(xiàng)
以易讀的方式顯示
total used free shared buffers cache available
Mem: 1881544 353752 881684 8712 147960 498148 1370492
Swap: 0 0 0
顯示物理內(nèi)存和交換內(nèi)存的總和
total used free shared buff/cache available
Mem: 1881544 354108 881328 8712 646108 1370136
Swap: 0 0 0
Total: 1881544 354108 881328
每隔N秒輸出一次
total used free shared buff/cache available
Mem: 1881544 353960 881476 8712 646108 1370284
Swap: 0 0 0
total used free shared buff/cache available
Mem: 1881544 353984 881452 8712 646108 1370260
Swap: 0 0 0
total used free shared buff/cache available
Mem: 1881544 353984 881452 8712 646108 1370260
Swap: 0 0 0
例子中的命令是每隔2秒輸出一次內(nèi)存信息,直到按?Ctrl + Z?停止
重復(fù)輸出N次
total used free shared buff/cache available
Mem: 1881544 353960 881476 8712 646108 1370284
Swap: 0 0 0
total used free shared buff/cache available
Mem: 1881544 353984 881452 8712 646108 1370260
Swap: 0 0 0
total used free shared buff/cache available
Mem: 1881544 353984 881452 8712 646108 1370260
Swap: 0 0 0
上面的例子是重復(fù)輸出內(nèi)存信息3次,每次間隔默認(rèn)是1秒,如果要修改默認(rèn)輸出間隔可以加上?-s 秒數(shù),下面的命令是:重復(fù)輸出3次,每次輸出間隔2秒
free -c 3 -s 2buff 和 cache 分開顯示
total used free shared buffers cache available
Mem: 1881544 354100 881328 8712 147968 498148 1370144
Swap: 0 0 0
以 Bytes、KB、MB、GB 為單位輸出
total used free shared buff/cache available
Mem: 1926701056 362446848 902631424 8921088 661622784 1403179008
Swap: 0 0 0
[root@ecs-centos-7 ~]# free -k
total used free shared buff/cache available
Mem: 1881544 354100 881328 8712 646116 1370144
Swap: 0 0 0
[root@ecs-centos-7 ~]# free -m
total used free shared buff/cache available
Mem: 1837 345 860 8 630 1338
Swap: 0 0 0
[root@ecs-centos-7 ~]# free -g
total used free shared buff/cache available
Mem: 1 0 0 0 0 1
Swap: 0 0 0
上面的例子中,分別以 Bytes、KB、MB、GB 為單位輸出內(nèi)存信息,會(huì)自動(dòng)忽略小于對(duì)應(yīng)單位的數(shù)值,比如?free -g命令,只有 total 和 available 列的值大于 1GB ( 1024 * 1024 * 1024 Bytes ), 其他列的值都是小于 1GB,所以 total 和 available 列顯示 1,其他列都顯示 0
實(shí)際還有多少可用內(nèi)存
[root@ecs-centos-7 ~]# free -htotal used free shared buff/cache available
Mem: 1.8G 534M 100M 8.5M 1.3G 1.5G
Swap: 0B 0B 0B
在上面的示例中,如果只是看 used 以及 free 的話,會(huì)以為系統(tǒng)可用內(nèi)存已經(jīng)不足100M,也即可使用內(nèi)存不足 1%了
實(shí)際上,已經(jīng)被應(yīng)用程序使用的只有 27%左右(534M / 1.8G), 應(yīng)用程序可用內(nèi)存是 availabe 或者 free + buff/cache ,也就是說(shuō)例子中實(shí)際可用于應(yīng)用程序的內(nèi)存有 1.5G 之多
內(nèi)存什么時(shí)候告急
在平常的服務(wù)器監(jiān)控內(nèi)存的過程中,有以下幾個(gè)信號(hào)是需要引起注意的
availabe 或者 free + buff/cache 接近于0了
availabe 或者 free + buff/cache 表示實(shí)際應(yīng)用程序的可用內(nèi)存,如果它接近于0的話,表示應(yīng)用程序可用內(nèi)存不足,需要盡快處理
已使用交換內(nèi)存一直在增長(zhǎng)
已使用交換內(nèi)存一直增長(zhǎng)的話,有可能是物理內(nèi)存不足的先兆,當(dāng)物理內(nèi)存長(zhǎng)時(shí)間不足的時(shí)候,才會(huì)頻繁的使用交換內(nèi)存,導(dǎo)致已使用交換內(nèi)存一直增長(zhǎng)
出現(xiàn) Out of memory
為了防止系統(tǒng)物理內(nèi)存不夠用的時(shí)候系統(tǒng)崩潰,當(dāng)檢測(cè)到內(nèi)存不足時(shí),系統(tǒng)會(huì) kill 掉最占用內(nèi)存的進(jìn)程,/var/log/message 中會(huì)記錄?Out of memory的日志
推薦閱讀
Linux 下 top 命令詳解
總結(jié)
以上是生活随笔為你收集整理的centos 没有nmtui命令_Linux free 命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Latex数学符号输入大全
- 下一篇: Linux日志高频使用命令