在Linux下使用命令查看服务器配置信息

  • 技术文档
  • 2021.12.21
  • 浏览:1562

在Linux下使用命令查看服务器配置信息

有许多命令可以用来查看 Linux 系统上的硬件信息。有些命令只能够打印出像 CPU 和内存这一特定的硬件组件信息,另外一些命令可以查看多种硬件组件的信息。这个教程可以带大家快速了解一下查看各种硬件设备的信息和配置详情的最常用的命令。

查看服务器型号

dmidecode | grep "System Information" -A9 | egrep "Manufacturer|Product"
    Manufacturer: Sugon
Product Name: W580-G20

查看操作系统

cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.3.1611 (Core) 
Release:    7.3.1611
Codename:   Core

查看CPU信息

cat /proc/cpuinfo
lscpu
Architecture:          x86_64
CPU op-mode(s):       32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):               12
On-line CPU(s) list:   0-11
Thread(s) per core:    1
Core(s) per socket:    6
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 63
Model name:            Intel(R) Xeon(R) CPU E5-2609 v3 @ 1.90GHz
Stepping:              2
CPU MHz:               1780.062
BogoMIPS:              3805.02
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              15360K
NUMA node0 CPU(s):     0-5
NUMA node1 CPU(s):     6-11

查看CPU型号

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     12  Intel(R) Xeon(R) CPU E5-2609 v3 @ 1.90GHz

查看逻辑CPU个数

cat /proc/cpuinfo |grep name |cut -d: -f2 |uniq -c
cat /proc/cpuinfo| grep "processor"| wc -l

查看物理CPU个数

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

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

cat /proc/cpuinfo | grep "cpu cores" | uniq
cpu cores   : 6

top命令

top后按1可以看到多少个CPU

查看磁盘信息

fdisk -l

查看内存的插槽数,已经使用多少插槽,每条内存多大

dmidecode | grep -A5 "Memory Device" | grep Size |grep -v Range
    Size: 32 GB
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: 32 GB
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed
    Size: No Module Installed

查看硬盘和分区分布

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 558.9G  0 disk 
├─sda1        8:1    0     1G  0 part /boot
└─sda2        8:2    0 557.9G  0 part 
  ├─cl-root 253:0    0    50G  0 lvm  /
  ├─cl-swap 253:1    0  31.4G  0 lvm  [SWAP]
  └─cl-home 253:2    0 476.5G  0 lvm  /home
sr0          11:0    1  1024M  0 rom 

查看网卡的硬件信息

lspci | grep -i 'eth'