Shell script to determine whether the Linux system is 32-bit or 64-bit methods to share the _linux shell

Source: Internet
Author: User

One line can be done, output 32 or 64.
You can use "getconf word_bit" and "getconf long_bit" to get the number of digits for WORD and LONG, and 32 and 64 for 64-bit systems respectively.
The reference code is as follows:

Copy Code code as follows:

Ldconfig
If [$ (getconf word_bit) = ' $ '] && [$ (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

Other method One: Execute command file/sbin/init

Copy Code code as follows:

[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/li Nux 2.6.18, stripped

That is 32-bit Linux, if 64-bit, the display is 64-bit.
For example, the result of running on another 64-bit machine:

Copy Code code as follows:

[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

Method Two: Uname-a

32 bits: 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 bits: Linux demolinux 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 19:59:55 UTC 2014 x86_64 x86_64 x86_64 gnu/linux

method Three: Use "getconf word_bit" and "getconf long_bit" to get WORD and LONG number of digits, 64-bit system should be 32 and 64 respectively.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.