30 December 2009 0 Comments

Find the Processor / CPU is 64 bit / 32 bit Under Ubuntu / Linux

If you have an Ubuntu installation, and want to check what version it is, you have a number of options.

One of the methods is to run

1
more /etc/issue

This will return something like this:

1
Ubuntu 9.10 \n \l

But this isn’t the best way.

You need to use uname command, which prints system information including kernel version and whether kernel is 32 bit or 64 bit. You can also use less /proc/cpuinfo command determine if it is 64 bit cpu or not.

Example – Find out if Running kernel is 32 or 64 bit

1
$ uname -a

Output:

1
Linux ora100 2.6.5-7.252-smp #1 SMP Tue Feb 14 11:11:04 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux

uname -a should show you if you have 64 bit kernel. If it doesn’t say 64 somewhere, it’s not 64 bit. Commonly 32-bit would be either i686 for most Linuxes and ia32 for RH Linux and derivatives. For example, x86_64 GNU/Linux indicates I have 64bit kernel running. If you use see i386/i486/i586/i686 it is a 32 bit kernel.

How do I find out CPU is 32bit or 64bit?

Simply type the following command and if you see lm in output, you have a 64 bit system:

1
$ grep flags /proc/cpuinfo

Output:

1
2
3
4
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 constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
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 constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
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 constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
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 constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
  • lm means Long mode – 64 bit CPU
  • Real mode 16 bit CPU
  • Protected Mode is 32-bit CPU

or run

$ cat /proc/cpuinfo | grep “lm”

will tell you if you have the lm flag, and thus if your processor is 64 bit.

Kernel vs. CPU

You can run 32 and 64 bit software at the same time on the same system as part of the same OS on a 64 bit processor, but you can’t run 64 bit software on 32 bit processor. (You can’t generally run 64 bit software on a 64 bit platform if your kernel is only 32 bits, however.)

You can run a 64 bit kernel with a 32 bit OS on a 64 bit processor, but not by default.

Since unfortunately far too frequently people run 32 bit kernels and operating systems on 64 bit hardware, it’s important to make the distinction between knowing what your hardware can actually support versus what it’s running right now. The ONLY quick way to know hardware capabilities is via /proc/cpuinfo. All of the other methods mentioned above are checking the OS to see what it’s doing.

1
$ cat /proc/cpuinfo | grep "lm"

will tell you if you have the lm flag, and thus if your processor is 64 bit.

On the other hand, you can’t run a 64 bit OS on a 32 bit processor (without virtualizing the processor itself) so if you have a 64 bit OS, then you must also have a 64 bit processor. If you have a 32 bit OS, then you must check a bit further because you might not be taking advantage of all of the powerful capabilities of your platform.