How To Get linux CPU Information
有时候知道服务器的 CPU 架构为 32 位或 64 位是否非常重要的,因为 64 位应用程序不能在 32 位系统上运行,而 32 位应用程序可以轻松运行在 64 位系统。
通过查看 /proc/cpuinfo 文件确定 CPU 体系结构,如下所示:
[root@localhost ~]# cat /proc/cpuinfo | grep -i flags
flags: 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 架构。
含义如下:
使用 lscpu 命令检查 CPU 架构,在输出中查找 “CPU op-modes(s)”
koogua@debian:~$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 25
Model: 80
Model name: AMD Ryzen 5 5600H with Radeon Graphics
Stepping: 0
CPU MHz: 3293.726
BogoMIPS: 6587.45
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32 KiB
L1i cache: 32 KiB
L2 cache: 512 KiB
L3 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
可以使用 lscpu,uname,getconf 命令,找到 Linux 系统是 32 位还是 64 位。
[root@localhost ~]# lscpu
输出如下:
koogua@debian:~$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 25
Model: 80
Model name: AMD Ryzen 5 5600H with Radeon Graphics
Stepping: 0
CPU MHz: 3293.726
BogoMIPS: 6587.45
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32 KiB
L1i cache: 32 KiB
L2 cache: 512 KiB
L3 cache: 16 MiB
使用 uname -m 命令,输出如下
[root@localhost ~]# uname -m
x86_64
使用 getconfig 命令,输出如下
[root@localhost ~]# getconf LONG_BIT
64