当前位置:   article > 正文

ubuntu如何查看系统信息、cpu型号_ubuntu查看cpu型号命令

ubuntu查看cpu型号命令

查看当前操作系统内核信息

uname -a
  • 1

输出:

Linux htu-H110M-S2 5.4.0-148-generic #165~18.04.1-Ubuntu SMP Thu Apr 20 01:14:06 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

查看当前操作系统发行版信息

cat /etc/issue
  • 1

Ubuntu 18.04.6 LTS \n \l

查看cpu型号

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
  • 1

4 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
(看到有4个逻辑CPU, 也知道了CPU型号)

查看物理cpu颗数

cat /proc/cpuinfo | grep physical | uniq -c
  • 1

1 physical id : 0
1 address sizes : 39 bits physical, 48 bits virtual
1 physical id : 0
1 address sizes : 39 bits physical, 48 bits virtual
1 physical id : 0
1 address sizes : 39 bits physical, 48 bits virtual
1 physical id : 0
1 address sizes : 39 bits physical, 48 bits virtual
2 physical id : 0
(说明实际上是1颗4核的CPU)

查看cpu运行模式

getconf LONG_BIT
  • 1

64

查看cpu是否支持64bit

cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
  • 1

4

(结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit)

查看cpu信息概要:

lscpu
  • 1

输出结果:

架构:           x86_64
CPU 运行模式:   32-bit, 64-bit
字节序:         Little Endian
CPU:             4
在线 CPU 列表:  0-3
每个核的线程数: 1
每个座的核数:   4
座:             1
NUMA 节点:      1
厂商 ID:        GenuineIntel
CPU 系列:       6
型号:           158
型号名称:       Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
步进:           9
CPU MHz:        800.126
CPU 最大 MHz:   3800.0000
CPU 最小 MHz:   800.0000
BogoMIPS:       6799.81
虚拟化:         VT-x
L1d 缓存:       32K
L1i 缓存:       32K
L2 缓存:        256K
L3 缓存:        6144K
NUMA 节点0 CPU: 0-3
标记:           fpu vme de ......
  • 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

最后来个大而全的:

cat /proc/cpuinfo
  • 1

输出结果:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
microcode       : 0xf0
cpu MHz         : 800.034
cache size      : 6144 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 ......
bugs            : cpu_meltdown spectre_v1 ...
bogomips        : 6799.81
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
microcode       : 0xf0
cpu MHz         : 800.110
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse......
bugs            : cpu_meltdown spectre_v1 ...
bogomips        : 6799.81
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
microcode       : 0xf0
cpu MHz         : 800.033
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 2
cpu cores       : 4
apicid          : 4
initial apicid  : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de ......
bugs            : cpu_meltdown spectre_v1 ...
bogomips        : 6799.81
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
microcode       : 0xf0
cpu MHz         : 800.033
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 3
cpu cores       : 4
apicid          : 6
initial apicid  : 6
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de ......
bugs            : cpu_meltdown spectre_v1 ...
bogomips        : 6799.81
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:
  • 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
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107

linux下通过C语言获取CPU个数信息

#include<stdio.h>
#include<unistd.h>

int main()
{
int cpu_num;

cpu_num = sysconf(_SC_NPROCESSORS_CONF);
printf("_SC_NPROCESSORS_CONF=%d/n",cpu_num);

cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
printf("_SC_NPROCESSORS_ONLN=%d/n",cpu_num);

return 0;
}

/* 
* - _SC_NPROCESSORS_CONF
*       The number of processors configured.
* 
* - _SC_NPROCESSORS_ONLN
*       The number of processors currently online (available).
*/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

Linux下获得CPU个数一个简单方法就是查看/proc/cpuinfo文件。

看出现processor字样的行数是多少条,即有多少个逻辑CPU(包括多核,超线程)。因此终端下输入下面命令即可:

cat /proc/cpuinfo | grep processor | wc -l
  • 1

输出:4

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/330504
推荐阅读
相关标签
  

闽ICP备14008679号