Linux Find If Processor (CPU) is 64 bit / 32 bit [long mode ~ lm] nixCraft Updated Tutorials/Posts

I am a new Linux system user. How do I determine if my CPU is 64bit or not on a Linux operating systems using command line option? How can I check Linux kernel is in 32 bit or 64 bit mode?

You need to use the following commands to find out information about Linux kernel and CPU architecture including if CPU is 64 bit or 32 bit:

  1. getconf LONG_BIT command: This command check if the OS (kernel) is 32 bit or 64 bit.
  2. uname command: This command prints system information including kernel version and whether kernel (os) is 32 bit or 64 bit.
  3. /proc/cpuinfo file: Use this file to determine if CPU is 64 bit or 32 bit i.e. find out CPU architecture.

How to find if Linux is running on 32-bit or 64-bit

  1. Open the Linux terminal application.
  2. Type uname -a to print system information.
  3. Run getconf LONG_BIT to see if Linux kernel is 32 or 64 bit.
  4. Execute grep -o -w 'lm' /proc/cpuinfo command to determine if you are using 32 or 64 bit CPU

Let us see all commands and examples in details.

Example – Find out if running Linux kernel (OS) is 32 or 64 bit

Type the following command at the terminal:
$ uname -a
Sample 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 that you’ve a 64bit Linux kernel running. If you use see i386/i486/i586/i686 it is a 32 bit kernel. You can also use the following command to find out if Linux kernel is running in 32bit or 64bit mode:
$ getconf LONG_BIT
Sample outputs:

64

NOTE: If you are running 32 bit cpu, you will see 32 bit as output.

How do I find out CPU is 32bit or 64bit on a Linux system?

Simply type the following grep command and if you see lm in output, you have a 64 bit CPU based system:
$ grep flags /proc/cpuinfo
OR
$ grep -o -w 'lm' /proc/cpuinfo | sort -u
Sample outputs:

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

(Scroll to see all flags)

More about CPU modes:

  • lm flag means Long mode cpu. In other words, Linux running on 64 bit cpu
  • Real mode 16 bit CPU
  • Protected Mode is 32-bit CPU

lshw command

lshw is a small command line tool to extract detailed information on the hardware configuration of the machine powered by Linux operating systems. To get CPU info run the following lshw command and look for width field:
sudo lshw -class processor
Sample outputs:

 *-cpu description: CPU product: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz vendor: Intel Corp. physical id: 3f bus info: cpu@0 version: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz serial: To Be Filled By O.E.M. slot: U3E1 size: 2782MHz capacity: 4200MHz
 width: 64 bits clock: 100MHz capabilities: x86-64 fpu fpu_exception wp vme de pse ts .... cpufreq configuration: cores=4 enabledcores=4 threads=8

Demo

Animated gif 01: Linux Find Out If Processor / CPU and OS (kernel) is in 32 or 64 bit mode
Animated gif 01: Linux Find Out If Processor / CPU and OS (kernel) is in 32 or 64 bit mode

Use lscpu to find if Linux running on 64 bit cpu

Simply type the following lscpu command
lscpu
Linux 64 bit cpu find command
From the above outputs it is clear that:

  • Architecture: x86_64 – Linux kernel is 62 bit
  • CPU op-mode(s): 32-bit, 64-bit – Your CPU can run 32 or 64 bit instructions i.e. Linux kernel.

Say hello to easy to use tool called inxi

inxi is a command line system information script built for for console and IRC. Simply install it using the apt command or apt-get command on a Debian or Ubuntu Linux:
sudo apt install inxi
Fedora user should try the dnf command:
sudo dnf install inxi
RHEL/CentOS user turn on EPEL repo and run the yum command:
sudo yum install inxi
Next, run inxi as follows or with the help of grep command:
inxi -Fxz
inxi -Fxz | grep bits

Linux 32 bit cpu command

Conclusion

You learned Linux commands to find out if your computer CPU is 32 bit or 64 bit. For more information see:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Posted by Web Monkey

Leave a Reply