How to check whether a CPU is 64 bit or 32 bit in Unix

Determine whether a CPU has 64 bit capability or not .

We know about uname command . Using it ,we can get similiar information, but that information is for the running version of the kernel . We need to know the 64 bit capability of the CPU  . This can be determined by either reading the /proc/cpuinfo file or by using the dmidecode command. Let's see how we can use those commands .


Using /proc/cpuinfo 

This virtual file gives information regarding the processors in computer . Among the information it provides are CPU vendor , speed and No of CPUs and many flags giving various features of the CPU.  Let's consider the following output of /proc/cpuinfo taken from my host.

zaman@personal-desk ~]$ cat /proc/cpuinfo 
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 7
model name : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping : 6
cpu MHz : 2992.520
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_cpl est tm2 xtpr
bogomips : 3985.98


processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 7
model name : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping : 6
cpu MHz : 2992.520
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_cpl est tm2 xtpr
bogomips : 3985.98

We need to read the flag parameter to determine a processor's 64 bit capability. Let's do a grep for flag from the above output.

$ grep flags /proc/cpuinfo 
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_cpl est tm2 xtpr
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_cpl est tm2 xtpr

On checking the above output, we can notice the 'lm' flag. 'lm' stands for long mode and this parameter determines that the processor has got 64 bit capability . If this flag value is missing, then the CPU does not have 64 bit capability.
This method of detemining whether a CPU is 64 bit or 32 bit works fine on a Linux host , but we cannot use it on other unix based hosts where there is no /proc/cpuinfo file . In such type of hosts , where there is no /proc/cpuinfo file , we can use the dmidecode command.


Using Dmidecode to determine a processor's 64 bit capability

On some Unix systems like FreeBSD , there is no /proc/cpuinfo file . We can determine the 64 bit capability on such systems using the dmidecode command. dmidecode will provide information regarding every hardware component in your computer .Let's see now using dmidecode to determine the 64 bit capability of a CPU.

-bash-3.2$ sudo dmidecode --type=processor | grep -i -A 1 charac 
Characteristics:
64-bit capable
--
Characteristics:
64-bit capable

This tells us that the CPU is 64 bit.

dmidecode is available for download from http://www.nongnu.org/dmidecode/ .
I have written another post on using the dmidecode tool . You can read more about the post here http://www.zaman4linux.in/2009/10/using-dmidecode-getting-bios.html .

Comments

Popular Posts