Tuesday, February 3, 2015

How to determine whether a given Linux is 32 bit or 64 bit?

Try uname -m. It seems like the uname -m actually gives

x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel
 
lscpu will list out these among other information regarding your CPU:

Architecture: x86_64 CPU 
op-mode(s): 32-bit, 64-bit

Another useful command for easy determination is as below:
Command:
getconf LONG_BIT
Answer:
  • 32, if OS is 32 bit
  • 64, if OS is 64 bit

 
In Bash, using integer overflow:
if ((1<<32)); then
  echo 64bits
else
  echo 32bits
fi
It's much more efficient than invoking another process or opening files.

No comments:

Post a Comment