Method One: getconf long_bit
Enter the getconf long_bit command on the Linux terminal
If it is a 32-bit machine, the result is 32
Linux Code
[Email protected] ~]# getconf long_bit
32
If it is a 64-bit machine, the result is 64
Linux Code
[Email protected] ~]# getconf long_bit
64
Method Two: Uname-a
If it is a 64-bit machine, it will output x86_64
Linux Code
[Email protected] ~]$ uname-a
Linux testweb01 2.6.18-308.4.1.el5 #1 SMP Tue Apr 17:08:00 EDT-x86_64 x86_64 x86_64 Gnu/linux
As you can see, the output of x86_64 in the results of the uname-a execution indicates that the machine is 64-bit, otherwise the machine is 32-bit
Linux Code
[Email protected] ~]# uname-a
Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Tue 15:51:54 EDT i686 i686 i386 gnu/linux
Method Three: File/sbin/init or File/bin/ls
Example: 32-bit machine
File/sbin/init
Linux Code
[Email protected] ~]# File/sbin/init
/sbin/init:elf 32-bit LSB executable, Intel 80386, version 1 (SYSV), for Gnu/linux 2.6.9, dynamically linked (uses shared LIBS), for Gnu/linux 2.6.9, stripped
File/bin/ls
Linux Code
[Email protected] ~]# File/bin/ls
/bin/ls:elf 32-bit LSB executable, Intel 80386, version 1 (SYSV), for Gnu/linux 2.6.9, dynamically linked (uses shared Li BS), for Gnu/linux 2.6.9, stripped
Example: 64-bit machine
File/sbin/init
Linux Code
[Email protected] ~]$ File/sbin/init
/sbin/init:elf 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for Gnu/linux 2.6.9, dynamically linked (uses shared LIBS), for Gnu/linux 2.6.9, stripped
File/bin/ls
Linux Code
[Email protected] ~]$ File/bin/ls
/bin/ls:elf 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for Gnu/linux 2.6.9, dynamically linked (uses shared Lib s), for Gnu/linux 2.6.9, stripped
The 64-bit or 32-bit in the command result can be used to determine whether the machine is 64-bit or 32-bit.
END