您的位置:首页 > 运维架构 > Linux

Linux判断CPU是32位还是64位,判断系统是32位还是64位

2011-09-23 14:39 746 查看
来源:http://be-evil.org/post-265.html

http://www.ipcpu.com/2010/08/linux-cpu-32-64/

uname -m

看到 i386/i686 就是 32位

看到 x86_64 就是 64位

方法B:



file /bin/bash

看到 ELF 32-bit LSB executable, Intel 80386 就是 32位

看到 ELF 64-bit LSB executable, x86-64 就是 64位

方法C:



getconf LONG_BIT

看到 32 就是 32位

看到 64 就是 64位

1、判断CPU是32位还是64位

这个问题比较有意思,网上给出的办法都是判断了系统的位数,不代表CPU的位数。详细的可以看下这个帖子:http://bbs2.chinaunix.net/viewthread.php?tid=1600422【比较经典的技术帖子和争论帖子】

方法:

[root@s2.ipcpu.com ~]# cat
/proc/cpuinfo | grep lm

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 syscall

nx lm constant_tsc
pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm

lm表示Long Mode – 64位CPU

2、判断系统是32位还是64位

[root@s1.ipcpu.com ~]# uname -a

Linux s1.ipcpu.com 2.6.18-164.el5PAE #1 SMP Thu Sep 3 04:10:44 EDT 2009 i686
i686 i386GNU/Linux

i686 i386均是32位操作系统

[root@s2.ipcpu.com ~]# uname -a

Linux s2.ipcpu.com 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 16:12:36 EST 2009 x86_64
x86_64 x86_64 GNU/Linux

x86_64位64位操作系统,有些地方也叫amd64,但并非就是AMD的CPU,而是64位是AMD先推出的。

另外getconf LONG_BIT也能判断当前系统字长。

如果你cpuinfo的输出有lm标志, 而uname -a命令的输出是i386或i686, 说明你是64位的CPU跑的32位的系统

参考资料:

http://blog.csdn.net/eiyaa/archive/2009/05/14/4184353.aspx

http://bbs2.chinaunix.net/viewthread.php?tid=1600422

http://www.linuxquestions.org/questions/linux-general-1/proc-cpuinfo-flag-lm-358563/

http://www.unixtutorial.org/2009/05/how-to-confirm-if-your-cpu-is-32bit-or-64bit/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: