如何查看 Linux是32位还是64位?

方法一:执行命令 file /sbin/init

[root@localhost jianbao]# file /sbin/init

 

/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

 

即是32位的 Linux, 若是64位的, 显示的是 64-bit 。

例如,在另一台 64 位机器运行的结果:

[root@edunosql ~]# file /sbin/init

 

/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

 

方法二:uname -a

32位:Linux localhost.localdomain 2.6.32-431.17.1.el6.i686 #1 SMP Wed May 7 20:52:21 UTC 2014 i686 i686 i386 GNU/Linux

64位:Linux demolinux 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

 

方法三:使用用“getconf WORD_BIT”和“getconf LONG_BIT”获得 word 和 long 的位数,64位系统中应该分别得到32和64。

ldconfig
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ] ; then
	ln -s /usr/local/mysql/lib/mysql /usr/lib64/mysql
else
	ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
fi

来源:http://blog.snsgou.com/post-135.html

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.