Linux Find If Processor / CPU is 64 bit / 32 bit ( long mode ~ lm )

Q. Quick question, how to determine if CPU is 64bit or not under Linux?

A. 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

$ uname -a
Output:

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

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:
$ grep flags /proc/cpuinfo
Output:

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

See also:

Updated for accuracy!

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 12 comments… read them below or add one }

1 tushar 01.29.08 at 6:05 am

Thanks for this short and sweet information without too much garbage….

2 dGuru 03.27.08 at 8:14 am

all methods above are wrong. If the system was installed with 32bit OS the result will always be 32 unless it has a 64bit Linux running.

The correct way to do is:

cat /proc/cpuinfo

and look for flag “lm” in the flags: column. If it’s there then it’s 64bit CPU no matter Intel or AMD.

3 Mukta Jindal 11.11.08 at 7:52 am

Thanks for this quick information. It was really helpful !!!

4 Amdocs 12.25.08 at 4:39 pm

You can also try this to find out if your CPU/Processor is 32 bit or 64 bit:
# getconf LONG_BIT
32

5 Max 01.08.09 at 6:42 pm

Yeah… my power5 (ppc64) returns 32 for
getconf LONG_BIT

6 BalaKumar 01.15.09 at 4:33 am

Thank U for Your Great post

7 Core User 01.17.09 at 3:06 pm

Awesome! Exactly what i needed.
Good Job Man!!!

8 saharey 02.02.09 at 5:59 am

I this info is confusing in my Linux box when I run this command:
cat /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc up pni cx16 lahf_lm

and my uname -a command gives this info:

#1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux

now what should I conclude does I am using both 32 and 64 bit?

9 Shlomi Aflalo 02.04.09 at 5:38 pm

saharey – it means that you are running a 32 bit kernel on a 64 bit cpu.

10 neelesh 03.11.09 at 1:42 pm

the info was great and very much helped me…
specially the one from ‘dguru’
thankyou once again….

11 sfcg 04.10.09 at 8:26 pm

cat /usr/include/asm/cpufeature.h

This will show you all the pertinent flags regarding your motherboards socket. If you have an AMD read the AMD defined features. If you have an Intel read the Intel defined features. I find that the ‘lm’ flag does show up on intel chips however so keep that in mind.

12 Ivan 05.18.09 at 11:46 am

What about:

# getconf LONG_BIT
32
# grep flags /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic 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 est cid cx16 xtpr lahf_lm

I know that this machine has 32bit processor, however, the lm flag is present. Does this make the lm flag unreliable for determining the cpu architecture?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , , , , , ,

Previous post: Fedora Linux reconfigure X server

Next post: Find out if package is installed in Linux