1. 查看CPU的位数
在linux平台, 可以使用uname查询CPU是64位(x86_64)还是32位(i686):
ubuntu 10.4.1 linux $ uname -m
i686
suse 11 linux $ uname -m
x86_64
redhat 6.2 linux $ name -m
x86_64
aix 6.1 unix $ uname -m
00008EBDD600
sunos 5.10 unix $ uname -m
sun4v
在linux平台, 或者使用命令'grep flags /proc/cpuinfo', 会出现"tm(transparent mode)", "rm(real mode)"或"lm(long mode)"中的一个, 分别表示16位, 32位, 64位.(不知道为什么, ubuntu中没有)
ubuntu 10.4.1 linux $ grep flags /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx rdtscp constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 sse4_1 sse4_2 popcnt aes xsave avx hypervisor ida arat
suse 11 linux $ grep flags /proc/cpuinfo
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm up rep_good pni cx16 popcnt hypervisor lahf_lm
redhat 6.2 linux $ grep flags /proc/cpuinfo
flags : fpu de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good unfair_spinlock pni cx16 popcnt hypervisor lahf_lm
aix 6.1 unix $ uname grep flags /proc/cpuinfo
grep: can't open /proc/cpuinfo
sunos 5.10 unix $ grep flags /proc/cpuinfo
grep: can't open /proc/cpuinfo
2. 查看系统内核的位数
使用命令:'getconf LONG_BIT'.
ubuntu 10.4.1 linux $ getconf LONG_BIT
32
suse 11 linux $ getconf LONG_BIT
64
redhat 6.2 linux $ getconf LONG_BIT
64
aix 6.1 unix $ getconf LONG_BIT
32
sunos 5.10 unix $ getconf LONG_BIT
32
References:
stackoverflow: How to determine whether a given Linux is 32 bit or 64 bit?
cyberciti: Linux Find If Processor / CPU is 64 bit / 32 bit ( long mode ~ lm )
linuxquestions: how to check linux kernel is 32 bit or 64 bit