linux命令查看机器配置

CPU:频率,型号
内存:型号,速率,容量...,
磁盘:容量,速率。。。
文件系统:....
网络带宽:....

福利:以下所有功能均集中在一个shell文件中,执行这个文件即可,结果如下


image.png
# bin/bash
outfile="comInfo"
echo '主机:' | tr -d '\n' >> $outfile
'hostname' | tr -d '\n' >> $outfile
echo "  " | tr -d '\n' >> $outfile
hostname -i >> $outfile
echo 'cpu逻辑核数:' | tr -d '\n' >> $outfile
cat /proc/cpuinfo | grep processor| wc -l >> $outfile
echo 'cpu信息:' | tr -d '\n' >> $outfile
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c >> $outfile
echo '内存大小:' | tr -d '\n' >> $outfile
cat /proc/meminfo | grep -i "memtotal" >> $outfile
echo 'linux系统版本信息:' | tr -d '\n' >> $outfile
cat /etc/redhat-release >> $outfile
echo 'linux内核版本:' | tr -d '\n' >> $outfile
uname  -r >> $outfile

一、cpu 和 mem

总核数 = 物理CPU个数 X 每颗物理CPU的核数
总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程

查看物理CPU个数

# cat /proc/cpuinfo | grep "physical id"| sort| uniq| wc -l

查看每个物理CPU中core的个数(即核数)

 # cat /proc/cpuinfo | grep "cpu cores"| uniq

查看逻辑CPU的个数

# cat /proc/cpuinfo | grep "processor"| wc -l

查看CPU信息(型号)

# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
(看到有8个逻辑CPU, 也知道了CPU型号)

总的命令:lscpu

$ lscpu
Architecture:          x86_64     #架构--这里的64指的位处理器
CPU op-mode(s):        32-bit, 64-bit  #
Byte Order:            Little Endian  #小端法
CPU(s):                40  #逻辑cpu颗数
On-line CPU(s) list:   0-39 #在线的cpu数量 有些时候为了省电或者过热的时候,某些CPU会停止运行
Thread(s) per core:    2   # 每个核心的线程数
Core(s) per socket:    10     # 每个插槽上有几个核心
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 79
Model name:            Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
Stepping:              1
CPU MHz:               1200.439
CPU max MHz:           3100.0000
CPU min MHz:           1200.0000
BogoMIPS:              4399.74
Virtualization:        VT-x
L1d cache:             32K  # 一级高速缓存 dcache 用来存储数据,这具体表示表示cpu的L1数据缓存
L1i cache:             32K  # 一级缓存(具体为L1指令缓存
L2 cache:              256K  #二级缓存
L3 cache:              25600K  #三级缓存
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts

查看内存大小

 # cat /proc/meminfo | grep -i "memtotal"
# getconf LONG_BIT
32

(说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit)

二、linux系统版本信息

linux常用发行版

  1. 方式一: lsb_release -a (适合所有linux)
    注意:如果提示“-bash: lsb_release: command not found” ,就需要手动安装 lsb_release 命令。使用 yum install -y redhat-lsb
LSB Version: :base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
  1. 方式二:适用于RedHat , CentOS
$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
  1. 方式三:通过查看软件包名来看查看系统版本
  • 适用于 redhat
$ rpm -q redhat-release
package redhat-release is not installed
  • 适用于 centos
$ rpm -q centos-release
centos-release-7-3.1611.el7.centos.x86_64

三、linux 内核版本

  1. 方式一:uname -a 或者 uname -r
$ uname  -a
Linux bjfk-pm-4-20-dev11.wdk 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ uname  -r
3.10.0-957.el7.x86_64
  1. 方式二:cat /proc/version
$ cat /proc/version
Linux version 3.10.0-957.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018

四、查看系统位数(查看机器字长)

  1. 方式一:直接看看有没有/lib64 目录。64位的系统会有/lib64和/lib两个目录,32位只有/lib一个
cd / | ls
  1. 方式二:getconf LONG_BIT
$ getconf  LONG_BIT
64
  1. 方式三:file /bin/ls 查看基本程序二进制信息
$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3d705971a4c4544545cb78fd890d27bf792af6d4, stripped

五、查看网卡信息

ifconfig
bond0: flags=5187  mtu 1500
        inet 10.44.233.149  netmask 255.255.255.128  broadcast 10.44.233.255
        inet6 fe80::e42:a1ff:fe45:4280  prefixlen 64  scopeid 0x20
        ether 0c:42:a1:45:42:80  txqueuelen 1000  (Ethernet)
        RX packets 816031830479  bytes 1001643221377350 (910.9 TiB)
        RX errors 0  dropped 271108  overruns 0  frame 0
        TX packets 1828246832518  bytes 2696767069936299 (2.3 PiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth01: flags=6211  mtu 1500
        ether 0c:42:a1:45:42:80  txqueuelen 1000  (Ethernet)
        RX packets 560872368831  bytes 702760326680459 (639.1 TiB)
        RX errors 0  dropped 143028  overruns 0  frame 0
        TX packets 888934739548  bytes 1311002992074992 (1.1 PiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth02: flags=6211  mtu 1500
        ether 0c:42:a1:45:42:80  txqueuelen 1000  (Ethernet)
        RX packets 255159411366  bytes 298882833037898 (271.8 TiB)
        RX errors 0  dropped 128080  overruns 0  frame 0
        TX packets 939312090678  bytes 1385764077690282 (1.2 PiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 53468055  bytes 4821613048 (4.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53468055  bytes 4821613048 (4.4 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

可以看到有2块网卡,eth01,eth02

$ ethtool eth01
Settings for eth01:
    Supported ports: [ FIBRE ]
    Supported link modes:   1000baseKX/Full
                            10000baseKR/Full
                            25000baseCR/Full
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Advertised link modes:  1000baseKX/Full
                            10000baseKR/Full
                            25000baseCR/Full
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Speed: 10000Mb/s
    Duplex: Full
    Port: FIBRE
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
    Current message level: 0x00000004 (4)
                   link
    Link detected: yes

可以看到网卡1的吞吐大小为10000Mb/s

六、路由查询

使用route -n命令查看Linux内核路由表
image.png

image.png

你可能感兴趣的:(linux命令查看机器配置)