关于linux:干货Linux-上-OSCPU内存硬盘信息查询

8次阅读

共计 8609 个字符,预计需要花费 22 分钟才能阅读完成。

前言

当咱们接手了一台或者几台服务器的时候,首先咱们有必要对服务器的根本配置有所意识,这样才能够隔靴搔痒,对当前的软件部署,零碎运维会有事倍功半的成果。

查问服务器的根本配置个别查问操作系统,CPU,内存,硬盘,上面进行逐个解说。

操作系统根本配置查问

1、查看操作系统版本

#cat /etc/redhat-release 这个命令次要是查看红帽发行的操作系统的版本号
[root@node5 ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
#cat /etc/issue 这个命令实用于大多数 linux 发行版
[root@node5 ~]# cat /etc/issue
S
Kernel r on an m

2、查看操作系统内核版本

[root@node5 ~]# uname -r
3.10.0-693.el7.x86_64

3、查看操作系统详细信息

[root@node5 ~]# uname -a
Linux node5 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
#从下面这段输入能够看出,该服务器主机名是 node5,linux 内核版本是 3.10.0-693.el7.x86_64,CPU 是 x86 架构
#该命令能够查看更多信息
[root@node5 ~]# more /etc/*release 
::::::::::::::
/etc/centos-release
::::::::::::::
CentOS Linux release 7.4.1708 (Core) 
::::::::::::::
/etc/os-release
::::::::::::::
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
::::::::::::::
/etc/redhat-release
::::::::::::::
CentOS Linux release 7.4.1708 (Core) 
::::::::::::::
/etc/system-release
::::::::::::::
CentOS Linux release 7.4.1708 (Core)

CPU 根本配置查问

1、名词解释

[root@node5 ~]# grep 'physical id' /proc/cpuinfo | sort -u | wc -l
1

2、查看 CPU 外围数量

[root@node5 ~]# grep 'core id' /proc/cpuinfo | sort -u | wc -l
4

3、查看 CPU 线程数

# 逻辑 cpu 数:个别状况下,逻辑 cpu= 物理 CPU 个数×每颗核数,如果不相等的话,则示意服务器的 CPU 反对超线程技术(HT:简略来说,它可使解决 #器中的 1 颗内核如 2 颗内核那样在操作系统中发挥作用。这样一来,操作系统可应用的执行资源扩充了一倍,大幅提高了零碎的整体性能,此时逻 #辑 cpu= 物理 CPU 个数×每颗核数 x2)[root@node5 ~]# cat /proc/cpuinfo| grep "processor"|wc -l
4
[root@node5 ~]# grep 'processor' /proc/cpuinfo | sort -u | wc -l
4

4、查看 CPU 型号

[root@node5 ~]# cat /proc/cpuinfo | grep name | sort | uniq
model name  : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
[root@node5 ~]# dmidecode -s processor-version | uniq   #应用 uniq 进行去重
Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz

5、查看 CPU 的详细信息

#CPU 有几个核,就会输入几个反复的信息
[root@node5 ~]# cat /proc/cpuinfo
processor  : 0
vendor_id  : GenuineIntel
cpu family  : 6
model    : 142
model name  : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
stepping  : 10
microcode  : 0x96
cpu MHz    : 2000.921
cache size  : 8192 KB
physical id  : 0
siblings  : 4
core id    : 0
cpu cores  : 4
apicid    : 0
initial apicid  : 0
fpu    : yes
fpu_exception  : yes
cpuid level  : 22
wp    : yes
flags    : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat
bogomips  : 4002.00
clflush size  : 64
cache_alignment  : 64
address sizes  : 43 bits physical, 48 bits virtual
power management:

6、查看 CPU 的详细信息

[root@node5 ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 142
Model name:            Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Stepping:              10
CPU MHz:               2000.921
BogoMIPS:              4002.00
Virtualization:        VT-x
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat
#CPU 配置总结
通过以上的查问,咱们能够晓得该服务器是 1 路 4 核的 CPU,CPU 型号是 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz,该 CPU 没有超线程。

内存根本配置查问

查问服务器内存

[root@node5 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3941         286        3446          19         208        3407
Swap:          2047           0        2047
#正文
#linux 的内存管理机制的思维包含(不敢说就是)内存利用率最大化。内核会把残余的内存申请为 cached,而 cached 不属于 free 领域。当零碎运 #行工夫较久,会发现 cached 很大,对于有频繁文件读写操作的零碎,这种景象会更加显著。直观的看,此时 free 的内存会十分小,但并不代表可##用的内存小,当一个程序须要申请较大的内存时,如果 free 的内存不够,内核会把局部 cached 的内存回收,回收的内存再调配给应用程序。所以# 对于 linux 零碎,可用于调配的内存不只是 free 的内存,还包含 cached 的内存(其实还包含 buffers)。#对于操作系统:#MemFree=total-used
#MemUsed  = MemTotal - MemFree
#对于应用程序:#MemFree=buffers+cached+free

每隔 3 秒查问一下内存

[root@node5 ~]# free -s 3
              total        used        free      shared  buff/cache   available
Mem:        4036316      361144     3458272       19536      216900     3419776
Swap:       2097148           0     2097148
              total        used        free      shared  buff/cache   available
Mem:        4036316      361144     3458272       19536      216900     3419776
Swap:       2097148           0     2097148
              total        used        free      shared  buff/cache   available
Mem:        4036316      361144     3458272       19536      216900     3419776
Swap:       2097148           0     2097148

硬盘根本配置查问

1、查问磁盘整体应用状况

[root@node5 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   17G  4.1G   13G  24% /
devtmpfs                 2.0G     0  2.0G   0% /dev
tmpfs                    2.0G  8.0K  2.0G   1% /dev/shm
tmpfs                    2.0G  8.7M  2.0G   1% /run
tmpfs                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda1               1014M  125M  890M  13% /boot
tmpfs                    395M     0  395M   0% /run/user/0
#命令拓展
#df -a 显示全副的文件系统的应用状况
#df - i 显示 inode 信息
#df -k 已字节数显示区块占用状况
#df -T 显示文件系统的类型

2、查问某个目录磁盘占用状况

# 命令拓展
#du -s 指定目录大小汇总
#du - h 带计量单位
#du -a 含文件
#du --max-depth=1 子目录深度
#du -c 列出明细的同时,减少汇总值
[root@node5 ~]# du -sh /home/
1.7G  /home/
[root@node5 ~]# du -ach --max-depth=2 /home/
4.0K  /home/www/.bash_logout
4.0K  /home/www/.bash_profile
4.0K  /home/www/.bashrc
4.0K  /home/www/web
16K  /home/www
4.0K  /home/nginx/.bash_logout
4.0K  /home/nginx/.bash_profile
4.0K  /home/nginx/.bashrc
12K  /home/nginx
4.0K  /home/esnode/.bash_logout
4.0K  /home/esnode/.bash_profile
4.0K  /home/esnode/.bashrc
4.0K  /home/esnode/.oracle_jre_usage
4.3M  /home/esnode/elasticsearch-analysis-ik-6.2.2.zip
80M  /home/esnode/kibana-6.2.2-linux-x86_64.tar.gz
300M  /home/esnode/x-pack-6.2.2.zip
28M  /home/esnode/elasticsearch-6.2.2.tar.gz
4.0K  /home/esnode/.bash_history
294M  /home/esnode/elasticsearch-6.2.2
4.0K  /home/esnode/.ssh
4.0K  /home/esnode/x-pack 生成的秘钥.txt
1014M  /home/esnode/kibana-6.2.2-linux-x86_64
8.0K  /home/esnode/.viminfo
1.7G  /home/esnode
1.7G  /home/
1.7G  total

3、查看目录构造

#tree 命令默认没有装置,须要手动装置一下
[root@node5 ~]# yum -y install tree
#- L 指定目录深度
[root@node5 ~]# tree -L 2 /home/
/home/
├── esnode
│   ├── elasticsearch-6.2.2
│   ├── elasticsearch-6.2.2.tar.gz
│   ├── elasticsearch-analysis-ik-6.2.2.zip
│   ├── kibana-6.2.2-linux-x86_64
│   ├── kibana-6.2.2-linux-x86_64.tar.gz
│   ├── x-pack-6.2.2.zip
│   └── x-pack347224237346210220347232204347247230351222245.txt
├── nginx
└── www
    └── web
6 directories, 5 files

4、以树状的格局显示所有可用的块设施信息

[root@node5 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    1G  0 disk 
└─sdb1            8:17   0  200M  0 part 
sr0              11:0    1 1024M  0 rom
#正文
#NAME —— 设施的名称
#MAJ:MIN —— Linux 操作系统中的每个设施都以一个文件示意,对块(磁盘)设施来说,这里用主次设施编号来形容设施。#RM —— 可挪动设施。如果这是一个可挪动设施将显示 1,否则显示 0。#TYPE —— 设施的类型
#MOUNTPOINT —— 设施挂载的地位
#RO —— 对于只读文件系统,这里会显示 1,否则显示 0。#SIZE —— 设施的容量

列出所有可用的设施、通用惟一识别码(UUID)、文件系统类型以及卷标

[root@node5 ~]# blkid
/dev/sda1: UUID="6503b4ad-2975-4152-a824-feb7bea1b622" TYPE="xfs" 
/dev/sda2: UUID="nqZ4uJ-ksnN-KzYS-N42b-00m3-Ohc2-BJXunP" TYPE="LVM2_member" 
/dev/sdb1: UUID="94396e17-4821-4957-aa76-d41f33958ff5" TYPE="xfs" 
/dev/mapper/centos-root: UUID="c1d38b37-821d-48e7-8727-3937ccc657a4" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="c2fcaf11-42d8-4e4c-bf9e-6464f0777198" TYPE="swap"

转自:人生的哲理
起源:https://www.cnblogs.com/rensh…

正文完
 0