Determine whether the Linux system is 32-bit or 64-bit by using Shell scripts
Output 32 or 64 rows.
You can use "getconf WORD_BIT" and "getconf LONG_BIT" to obtain the number of digits of word and long. In a 64-bit system, 32 and 64 are obtained respectively.
The reference code is as follows:
View source?
1
ldconfig
2
if
[ $(getconf WORD_BIT) =
'32'
] && [ $(getconf LONG_BIT) =
'64'
] ;
then
3
ln
-s /usr/
local
/mysql/lib/mysql /usr/lib64/mysql
4
else
5
ln
-s /usr/
local
/mysql/lib/mysql /usr/lib/mysql
6
fi
Other methods 1: Execute the command file/sbin/init
1
[root@localhost jianbao]
# file /sbin/init
2
/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
In 32-bit Linux, 64-bit is displayed.
For example, the result of running on another 64-bit machine:
1
[root@edunosql ~]
# file /sbin/init
2
/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 2: uname-
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
Method 3: Use "getconf WORD_BIT" and "getconf LONG_BIT" to obtain the number of digits of word and long. The 64-bit system should obtain 32 and 64 respectively.