[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: the "proper" way to identify the bitness of your kernel and CPU



On Fri, 2009-04-03 at 14:34 -0400, Robert P. J. Day wrote:
> what is the fedora-approved way to identify the wordsize of both
> your running kernel and your CPU?  for the kernel, i'm used to running
> 
>   $ uname -r
> 
> and just looking at the suffix, which in my case would be either
> "i686" or "x86_64".  is there a simpler way?  does one of the "uname"
> options reliably report just that portion -- the wordsize of the
> running kernel?
> 
>   and, secondly, regardless of the bitness of the kernel, what about
> identifying the wordsize of the actual CPU (since you can obviously
> have a 32-bit kernel running on an x86_64 CPU).
> 
>   my standard tricks are one of:
> 
>   $ grep lm /proc/cpuinfo    (where "lm" stands for long mode)
>   $ getconf LONG_BIT         (should print 32 or 64)
> 
> in that second case, would "uname -p" reliably show a 64-bit CPU, even
> with a 32-bit OS?
> 
>   thanks.
> 
> rday
> --
> 

Try this script, I think I got this from one of the guys on the Centos
list.

Greg Ennis

#!/bin/bash
echo -n "Running "
RES=`uname -a | grep 64`
if [ $? -eq 0 ]; then
   echo -n "64-bit "
 else
   echo -n "32-bit "
fi
echo -n "operating system on a "
RES=`cat /proc/cpuinfo | grep " lm "`
if [ $? -eq 0 ]; then
   echo -n "64-bit "
else
   echo -n "32-bit "
fi
echo "machine"




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]