Linux自定義內存使用率命令

內存查看命令:free

自定義命令:alias

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:       8302800    7965944     336856          0      47184    5046216
-/+ buffers/cache:    2872544    5430256
Swap:      5668856        208    5668648

Linux總內存量:total, 可用內存:free+buffers+cached,已用內存 total-(free+buffers+cached)

爲了方便查看內存使用率,自定義命令如下

[root@localhost ~]# alias lsfree="free|awk '{print \$2,\$3,\$4,\$6,\$7}'|sed -n '2p'|awk '{print \"total:\"\$1/1024\"MB\",\"free:\"(\$3+\$4+\$5)/1024\"MB\",\"proportion:\"(\$3+\$4+\$5)/\$1*100\"%\"}'"

改爲永久生效:切換至目錄(centos) ~/.bashrc, 添加以上命令,保存,立即生效:source ~/.bashrc 

[root@localhost ~]# more .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias lsfree="free|awk '{print \$2,\$3,\$4,\$6,\$7}'|sed -n '2
p'|awk '{print \"total:\"\$1/1024\"MB\",\"free:\"(\$3+\$4+\$5)
/1024\"MB\",\"proportion:\"(\$3+\$4+\$5)/\$1*100\"%\"}'"
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[root@localhost ~]# lsfree
total:8108.2MB free:5297.31MB proportion:65.3327%




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章