How does Linux use the shell to see whether Linux is 32-bit or 64 bit


Now most users use the windows system. They all know that the windows system is divided into 32-bit and 64 bit. In fact, the Linux system is also divided into 32-bit and 64 bit. Do you know how many bits your Linux system is? The following small series will teach you how to use the shell to check whether Linux is 32-bit or 64 bit.


Manually view system bits

To view the number of bits in the Linux system, you can execute the following two commands respectively

  getconf WORD_BIT

Number of bits used to get word

  getconf LONG_BIT

Number of bits used to get long

For 64 bit systems, the above two commands should get 32 and 64 respectively.

There are many ways to judge whether the Linux system is 32-bit or 64 bit. Getconf is recommended. However, some people think that getconf word_ Bit = 32 is 32bit, getconf word_ Bit = 64 is 64bit. Please run it on the 64bit machine, hehe. getconf WORD_ Bit display result or 32, why?

In 32-bit systems, the int type and long type are generally 4 bytes. In 64 bit systems, the int type is still 4 bytes, but long has become an 8-byte variable in inux systems

Use “getconf” word_ Bit “and” getconf long “_ Bit “gets the digits of word and long

Shell judge system bits


  if [ $(getconf WORD_BIT) = ‘32’ ] && [ $(getconf LONG_BIT) = ‘64’ ] ; then

  ln -s /usr/local/mysql/lib/mysql /usr/lib64/mysql


  ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql


Add some other methods

  uname -a

32 bit: 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 bit: 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

The above is how Linux uses the shell to view Linux 32-bit and 64 bit. In addition to using the shell, you can also manually execute commands to view the system bits.

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]