Linux下轻松确定CPU是32位还是64位

 2023-11-15    92  

How To Get Linux CPU Information

有时候知道服务器的 CPU 架构为 32 位或 64 位是否非常重要的,因为 64 位应用程序不能在 32 位系统上运行,而 32 位应用程序可以轻松运行在 64 位系统。

确定 CPU 是 32 位还是 64 位?

通过查看 /proc/cpuinfo 文件确定 CPU 体系结构,如下所示:

[root@localhost ~]# cat /proc/cpuinfo | grep -i flagsflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc up rep_good pni monitor ssse3 lahf_lm

在上面的输出中,我们可以看到 lm, tm,rm,这些标志表示 CPU 架构。

含义如下:

  • lm : Long Mode (64 bit)
  • tm : Transparent Mode ( 32 bit)
  • rm : Real Mode (16 bit)

使用 lscpu 命令检查 CPU 架构,在输出中查找 “CPU op-modes(s)”

koogua@debian:~$ lscpuArchitecture:                    x86_64CPU op-mode(s):                  32-bit, 64-bitByte Order:                      Little EndianAddress sizes:                   48 bits physical, 48 bits virtualCPU(s):                          1On-line CPU(s) list:             0Thread(s) per core:              1Core(s) per socket:              1Socket(s):                       1NUMA node(s):                    1Vendor ID:                       AuthenticAMDCPU family:                      25Model:                           80Model name:                      AMD Ryzen 5 5600H with Radeon GraphicsStepping:                        0CPU MHz:                         3293.726BogoMIPS:                        6587.45Hypervisor vendor:               KVMVirtualization type:             fullL1d cache:                       32 KiBL1i cache:                       32 KiBL2 cache:                        512 KiBL3 cache:                        16 MiB

使用 lshw --class processor 命令查看 CPU 架构

koogua@debian:~$ sudo lshw -class processor  *-cpu       product: AMD Ryzen 5 5600H with Radeon Graphics       vendor: Advanced Micro Devices [AMD]       physical id: 2       bus info: cpu@0       width: 64 bits       capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp x86-64 constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand hypervisor lahf_lm cr8_legacy abm sse4a misalignsse 3dnowprefetch vmmcall fsgsbase bmi1 bmi2 invpcid rdseed clflushopt arat

使用 dmidecode 命令查看 CPU 体系结构

[root@localhost ~]# dmidecode -t processor

确定 Linux 是 32 位还是 64 位?

可以使用 lscpu,uname,getconf 命令,找到 Linux 系统是 32 位还是 64 位。

[root@localhost ~]# lscpu

输出如下:

koogua@debian:~$ lscpuArchitecture:                    x86_64CPU op-mode(s):                  32-bit, 64-bitByte Order:                      Little EndianAddress sizes:                   48 bits physical, 48 bits virtualCPU(s):                          1On-line CPU(s) list:             0Thread(s) per core:              1Core(s) per socket:              1Socket(s):                       1NUMA node(s):                    1Vendor ID:                       AuthenticAMDCPU family:                      25Model:                           80Model name:                      AMD Ryzen 5 5600H with Radeon GraphicsStepping:                        0CPU MHz:                         3293.726BogoMIPS:                        6587.45Hypervisor vendor:               KVMVirtualization type:             fullL1d cache:                       32 KiBL1i cache:                       32 KiBL2 cache:                        512 KiBL3 cache:                        16 MiB

使用 uname -m 命令,输出如下

[root@localhost ~]# uname -m x86_64

使用 getconfig 命令,输出如下

[root@localhost ~]# getconf LONG_BIT 64

我的开源项目

酷瓜云课堂 - 开源在线教育解决方案

  • course-tencent-cloud(酷瓜云课堂 - gitee 仓库)
  • course-tencent-cloud(酷瓜云课堂 - github 仓库)
  •  标签:  

原文链接:http://www.tpbz008.cn/post/44818.html

=========================================

http://www.tpbz008.cn/ 为 “电脑技术吧” 唯一官方服务平台,请勿相信其他任何渠道。

热门标签
最新留言
友情链接