【存储空间】df -h

df命令作用是列出文件系统的整体磁盘空间使用情况。可以用来查看磁盘已被使用多少空间和还剩余多少空间。

而df -h则是以人们易读的方式展示

[root@localhost home]# df -h 
filesystem size used avail use% mounted on 
/dev/mapper/cl-root 50g 36g 15g 71% / 
/dev/sda1 1014m 227m 788m 23% /boot 
/dev/mapper/cl-home 1.8t 450g 1.4t 25% /home 
filesystem:代表该文件系统时哪个分区,所以列出的是设备名称。
mounted on:磁盘挂载的目录,即该磁盘挂载到了哪个目录下面。

【内存】 free -h

free命令可以显示linux系统中空闲的、已用的物理内存及swap内存,及被内核使用的buffer。

一般用free -h方式查看内存占用情况(同样是适于人类阅读)

[root@localhost home]# free -h 
 total used free shared buffers cached 
mem: 126g 124g 2.0g 1.6m 626m 118g 
-/+ buffers/cache: 4.5g 121g 
swap: 15g 40m 15g 

注解:-buffers/cache反映的是被程序实实在在吃掉的内存(本例中,-buffers/cache的内存数是4.5g,即等于mem行的 used- buffers – cached),而+buffers/cache反映的是可以挪用的内存总数(本例中,+buffers/cache的内存数是121g,即等于mem行的free + buffers + cached)。

swap行数据是交换分区swap的,也就是我们通常所说的虚拟内存。当你看见 buffer/cache 的空闲空间低或者 swap 的空闲空间低,说明内存需要升级了。这意味这内存利用率很高。请注意 shared(共享)内存列应该被忽略 ,因为它已经被废弃了。

以上关于free -h的注解,部分参考自
https://www.cnblogs.com/kex1n/p/6010496.html。

关于buffers 和cache的解释,来自知乎
https://www.zhihu.com/question/26190832的解释,比较容易懂。

buffer的核心作用是用来缓冲,缓和冲击。比如你每秒要写100次硬盘,对系统冲击很大,浪费了大量时间在忙着处理开始写和结束写这两件事嘛。用个buffer暂存起来,变成每10秒写一次硬盘,对系统的冲击就很小,写入效率高了。cache的核心作用是加快取用的速度。比如你一个很复杂的计算做完了,下次还要用结果,就把结果放手边一个好拿的地方存着,下次不用再算了。加快了数据取用的速度。所以,如果你注意关心过存储系统的话,你会发现硬盘的读写缓冲/缓存名称是不一样的,叫write-buffer和read-cache。很明显地说出了两者的区别。

【cpu】 cat /proc/cpuinfo

利用cat查看服务器cpu info
[root@localhost home]# cat /proc/cpuinfo|grep "processor" |wc -l 
32 
[root@localhost home]# cat /proc/cpuinfo|grep "physical id" |sort|uniq|wc -l 
4 
[root@localhost home]# cat /proc/cpuinfo|grep "cpu cores" |uniq 
cpu cores : 8 

注解:以上三个命令从上自下分别代表①总逻辑cpu数:32;②物理cpu个数:4,这边如果是2就代表着是两路服务器,4则是四路服务器;③每颗物理cpu的核数:8。总逻辑cpu数=物理cpu个数×每颗物理cpu的核数。如果存在超线程技术,那么可以让单核模拟多核心工作,单核心具有两个线程。那么,总逻辑cpu数 = 物理cpu个数×每颗物理cpu的核数×超线程数。

【内核|操作系统】

查看内核版本 cat /proc/version | uname -a
查看操作系统 lsb_release -a | cat /etc/redhat-release | cat /etc/issue
[root@tc6000 evm_combine]# cat /proc/version 
linux version 2.6.32-642.el6.x86_64 (mockbuild@worker1.bsys.centos.org) (gcc version 4.4.7 20120313 (red hat 4.4.7-17) (gcc) ) #1 smp tue may 10 17:27:01 utc 2016 
[root@tc6000 evm_combine]# uname -a 
linux tc6000 2.6.32-642.el6.x86_64 #1 smp tue may 10 17:27:01 utc 2016 x86_64 x86_64 x86_64 gnu/linux 
#cat /proc/version 和uname -a 均可以查看到内核版本为2.6.32-642.el6.x86_64 
#2.6.32 代表版本号 -642代表版本号 
#el6 代表 发行版版本标识,rhel6centos6oracle linux6 一般都是el6 
#x86_64 代表64位系统 一般i386代表是32位 
[root@tc6000 evm_combine]# lsb_release -a 
lsb version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch 
distributor id: centos 
description: centos release 6.8 (final) 
release: 6.8 
codename: final 
[root@tc6000 evm_combine]# cat /etc/redhat-release 
centos release 6.8 (final) 
[root@tc6000 evm_combine]# cat /etc/issue 
centos release 6.8 (final) 
kernel 
 on an m 
#lsb_release -a cat /etc/redhat-release cat /etc/issue 三个命令都得到操作系统是centos, 但这三个命令并不适用每台linux机器