Linux查看CPU信息

Linux查看CPU信息

参数说明:

  • Physical id 相同表示为同一个物理CPU
  • Processor 表示逻辑CPU
  • Cpu cores CPU核数,内核个数
  • Core id 内核id号
  • Siblings 每个物理CPU里面的逻辑CPU个数

物理CPU 两个

processor  0      processor  2       processor   4          processor   6
core id    0      core id    2       core id     1          core id     3
physical   0      physical   0       physical    0          physical    0
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4        siblings   4          siblings    4

processor  1      processor  3       processor   5          processor   7
core id    0      core id    2       core id     1          core id     3
physical   1      physical   1       physical    1          physical    1
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4       siblings   4           siblings    4
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

计算是否开启超线程

逻辑CPU  >  物理CPU  x   CPU核数  #开启超线程
逻辑CPU  =  物理CPU  x   CPU核数  #没有开启超线程或不支持超线程
  • 1
  • 2
  • 1
  • 2

查看物理CPU个数

cat /proc/cpuinfo | grep “physical id” | sort -u | wc -l
2
  • 1
  • 2
  • 1
  • 2

查看逻辑CPU个数

cat /proc/cpuinfo | grep “processor” | wc -l
8
  • 1
  • 2
  • 1
  • 2

查看CPU内核数

cat /proc/cpuinfo | grep “cpu cores” | uniq
4
  • 1
  • 2
  • 1
  • 2

查看单个物理CPU封装的逻辑CPU数量

cat /proc/cpuinfo | grep “siblings” | uniq
4
  • 1
  • 2
  • 1
  • 2

script查看CPU信息

#!/bin/bash

physical=$(cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l)
processor=$(cat /proc/cpuinfo | grep "processor" | wc -l)
cpucores=$(cat /proc/cpuinfo  | grep "cpu cores" | uniq)
siblings=$(cat /proc/cpuinfo  | grep "siblings"  | uniq)

echo "* * * * * CPU Information is a : * * * * *"
echo "physical id is a : $physical"
echo "processor is a   : $processor"
echo "cpu cores is a   : $cpucores"
echo "siblings is a    : $siblings"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

判断CPU是32位的还是64位的

cat /proc/cpuinfo | grep lm 
8 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 lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx tm2 ssse3 cx16 xtpr pdcm dca sse4_1 xsave lahf_lm dts tpr_shadow vnmi flexpriority
lm 表示Long Mode - 64位CPU
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

判断系统是32位的还是64位的

uname -a 
i386  i686 代表32位操作系统
X86_64     代表64位操作系统
Linux 系统中查看 CPU 的相关信息,包括 CPU 型号、核心数以及使用情况,可以通过多种方式实现。以下是具体的操作方法和命令: ### 查看 CPU 型号 可以通过以下命令查看 CPU 的型号信息: ```bash cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c ``` 此命令会显示 CPU 的型号名称,例如 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz。该信息是从 `/proc/cpuinfo` 文件中提取的,该文件包含了 CPU 的详细规格信息[^1]。 ### 查看 CPU 核心数 要查看 CPU 的核心数,可以使用以下命令: ```bash cat /proc/cpuinfo | grep "cpu cores" | uniq ``` 此命令会显示每个物理 CPU 的核心数。如果系统中有多个物理 CPU,则需要结合其他命令来获取总的 CPU 核心数[^1]。 ### 查看 CPU 使用情况 为了查看 CPU 的实时使用情况,可以使用 `top` 或 `htop` 命令: ```bash top ``` 或者安装 `htop`(如果未安装): ```bash sudo apt-get install htop htop ``` 这些工具提供了动态的系统监视界面,可以实时查看 CPU 使用率、内存使用情况以及其他系统资源的状态[^1]。 ### 使用 `lscpu` 命令 另外,还可以使用 `lscpu` 命令来获取 CPU 架构的信息,包括 CPU 核心数、线程数等: ```bash lscpu ``` 此命令会输出详细的 CPU 架构信息,包括但不限于 CPU 核心数、线程数、CPU 架构类型等。 ### 使用 `cpufreq-info` 命令 对于需要查看 CPU 频率信息的情况,可以使用 `cpufreq-info` 命令,该命令属于 `cpufrequtils` 包: ```bash cpufreq-info ``` 这条命令展示了 CPU 当前运行的硬件频率,包括 CPU 所允许的最小/最大频率、CPUfreq 策略/统计数据等[^3]。 通过上述命令,可以在 Linux 系统中有效地获取 CPU 的相关信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值