Linux查看系统配置

CPU

lscpu

显示cpu架构信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[xxx@localhost ~]$ lscpu
Architecture: x86_64 # 架构
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 48          # 总处理器核心数量
On-line CPU(s) list: 0-47
Thread(s) per core: 2          # 每个核心支持的线程数量。1表示只支持一个线程,即不支持超线程
Core(s) per socket: 12          # 每个 插槽(处理器/物理cpu)的核心数量
Socket(s): 2          # 座/插槽:处理器数量
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 85 # 型号
Model name: Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz
Stepping: 7 # 步进
CPU MHz: 999.963
CPU max MHz: 3200.0000
CPU min MHz: 1000.0000
BogoMIPS: 4400.00
Virtualization type: VT-x # cpu支持的虚拟化技术
L1d cache: 32K # 一级缓存(具体表示cpu的L1数据缓存)
L1i cache: 32K # 一级缓存(具体为L1指令缓存)
L2 cache: 1024K
L3 cache: 16896K
NUMA node0 CPU: 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46
NUMA node1 CPU: 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47

[xxx@localhost ~]$ man lscpu
COLUMNS
CPU The logical CPU number of a CPU as used by the Linux kernel.     # 逻辑CPU数量
CORE The logical core number. A core can contain several CPUs.      # 逻辑核心数量
SOCKET The logical socket number. A socket can contain several cores.    # 逻辑插槽(路)数量

对操作系统来说,逻辑 CPU 的数量 = Socket * Core * Thread。

举例来说,如果某个服务器“2 路 4 核 超线程”,也就是 2 个插槽,4 核心,默认为 2 thread,即 242 是 16 逻辑 CPU。

  • Socket 具体是指的主板上 CPU 的插槽数量,一般笔记本只有一个,而服务器可能会有多个。如果有两个插槽,通常称为两路;
  • Core 具体是指 CPU 的核心,也就是平常说的几核,比如八核之类;
  • thread 是指的每个 Core 的硬件线程数,超线程

cat /proc/cpuinfo

查看 CPU 详细信息(内容过多,使用管道符以及grep命令过滤)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 查看物理CPU个数
cat /proc/cpuinfo | grep "physical id" | sort | uniq

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo | grep "cpu cores" | uniq

# 查看每个物理CPU中线程的个数
cat /proc/cpuinfo | grep "siblings" | uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"

# 查看CPU型号
cat /proc/cpuinfo | grep "model name" | uniq

# grep 命令用于查找文件里符合条件的字符串
# uniq 命令用于检查及删除文本文件中重复出现的行列,一般与 sort 命令结合使用

内存

查看**/proc/meminfo**或者使用**free**命令。free命令就是从meminfo中获取的信息。

硬盘

lsblk

blk 是 block 的缩写。列出块设备。

1
2
3
4
5
6
7
8
9
10
11
[xxx@localhost ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 100G 0 part /data
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 59.5G 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 50G 0 lvm /
├─VolGroup-lv_swap (dm-1) 253:1 0 4G 0 lvm [SWAP]
└─VolGroup-lv_home (dm-2) 253:2 0 5.6G 0 lvm /home

其中,TYPE=disk表示硬盘。可以看出,硬盘分为 sda 和 sdb,一共 160G。

df

查看硬盘使用情况。

1
2
3
4
5
6
7
[xxx@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 1.7G 46G 4% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-lv_home 5.5G 165M 5.1G 4% /home
/dev/sdb1 99G 188M 94G 1% /data

网卡

1
2
# lspci | grep -i 'eth'  # 未找到命令
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

查看系统的所有网络接口

1
2
3
4
5
[root@localhost ~]# ifconfig -a
eth0 Link encap:以太网 硬件地址 b8:97:5a:17:b3:8f
.....
lo Link encap:本地环回
.....

如果要查看某个网络接口的详细信息,例如 eth0 的详细参数和指标

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@localhost ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full #支持千兆半双工,全双工模式
Supported pause frame use: No
Supports auto-negotiation: Yes #支持自适应模式,一般都支持
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes #默认使用自适应模式
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
.....
Speed: 100Mb/s #现在网卡的速度是100Mb,网卡使用自适应模式,所以推测路由是100Mb,导致网卡从支持千兆,变成要支持百兆
Duplex: Full #全双工
.....
Link detected: yes #表示有网线连接,和路由是通的

查看Linux内核版本命令(2种方法)

Linux内核版本介绍与查询 - Smah - 博客园

cat /proc/version

1
2
[root@localhost ~]# cat /proc/version
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

major.minor.patch-build.desc:3.10.0-1160.el7

major : 主版本号,有结构变化才变更

minor : 次版本号,新增功能时才发生变化,一般技术表示测试版,偶数表示生产版

patch : 补丁包数或次版本的修改次数

build : 编译(或构建)的次数,每次编译可能对少量程序做优化或修改,但一般没有大的(可控的)功能变化。

desc : 当前版本的特殊信息,其信息由编译时指定,具有较大的随意性,有如下的标识是常用的:

​ rc(或r),表示发行候选版本(release candidate),rc后的数字表示该正式版本的第几个候选版本,多数情况下,各候选版本之间数字越大越接近正式版。

​ smp,表示对称多处理器(Symmetric MultiProcessing)。

​ pp,在Red Hat Linux中常用来表示测试版本(pre-patch)。

​ EL,在Red Hat Linux中用来表示企业版Linux(Enterprise Linux)。

​ mm,表示专门用来测试新的技术或新功能的版本。

​ fc,在Red Hat Linux中表示Fedora Core。

uname -a

1
2
[root@localhost ~]# uname -a
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020

查看Linux系统版本的命令(3种方法)

lsb_release -a,

列出所有版本信息:

未找到命令……

cat /etc/redhat-release

这种方法只适合 Redhat 系的 Linux

cat /etc/issue

此命令也适用于所有的 Linux 发行版。

其他

查看 pci 信息

即主板所有硬件槽信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost ~]# lspci  # 未找到命令
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) #主板芯片
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) #显卡
00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04) #usb控制器
00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04) #声卡
00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4) #pci 插槽
00:1c.2 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 3 (rev c4)
00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04)
00:1f.2 IDE interface: Intel Corporation Panther Point 4 port SATA Controller [IDE mode] (rev 04) #硬盘接口
00:1f.3 SMBus: Intel Corporation Panther Point SMBus Controller (rev 04)
00:1f.5 IDE interface: Intel Corporation Panther Point 2 port SATA Controller [IDE mode] (rev 04) #硬盘接口
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) #网卡
03:00.0 PCI bridge: Integrated Technology Express, Inc. Device 8893 (rev 41)

查看bios信息

1
2
3
4
5
6
7
8
9
[root@localhost ~]# dmidecode -t bios
......
BIOS Information
Vendor: American Megatrends Inc.
Version: 4.6.5
Release Date: 04/25/2012
.......
BIOS Revision: 4.6
......

Linux查看系统配置
https://blog-21n.pages.dev/2022/09/15/Linux查看系统配置/
作者
Neo
发布于
2022年9月15日
许可协议