Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Linux use shell to see if Linux is 32-bit or 64-bit?

Shulou Source: shulou.com Published: 2022-06-01 15:49:22 10月25日 Update

This article mainly explains how Linux uses shell to check whether Linux is 32-bit or 64-bit. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use shell to check whether Linux is 32-bit or 64".

Nowadays, most users use Windows system, and they all know that Windows system has 32-bit and 64-bit. In fact, Linux system also has 32-bit and 64-bit. Do you know how many bits your Linux system is? The editor will teach you how to use shell to see if Linux is 32-bit or 64-bit.

Manually check the number of system digits

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

Getconf WORD_BIT

The number of digits used to get word

Getconf LONG_BIT

The number of digits 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 a linux system is 32-bit or 64-bit. It is recommended to use getconf. However, some people think that getconf WORD_BIT=32 is 32-bit WORD_BIT=64 and getconf is 64bit. Please execute it on the 64bit machine, hehe. Getconf WORD_BIT shows the result or 32 why?

The int type and long type are generally 4 bytes in 32-bit systems and 4 bytes in 64-bit systems, but long has become available in 8-byte inux systems.

Get the number of digits of word and long with "getconf WORD_BIT" and "getconf LONG_BIT"

Shell judges the number of system digits

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

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 GNU/Linux

At this point, I believe you have a deeper understanding of "how Linux uses shell to check whether Linux is 32-bit or 64". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: System or digits bytes methods types two content commands learning utility deeper interest practicality practical manual easy to operate more friends machines Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei NVidia MariaDB Docker