Linux check 64 or 32 bit

How do I know if my Linux is 32 bit or 64 bit?

Let us see all commands to Find if Linux is running on 32-bit or 64-bit systems.

How do I know if my Linux is 32 bit or 64 bit?

To know information about the CPU architecture, type the following lscpu command:
lscpu

From the above output it is clear that I have:

  • CPU: AMD Ryzen 7 1700 Eight-Core Processor
  • Architecture: x86_64
  • CPU can run: 32bit or 64-bit operating system

Find out CPU is 32bit or 64bit on a Linux system

Simply run the following grep command:
grep -o -w ‘lm’ /proc/cpuinfo | sort -u
Sample outputs:

The lm flag means long mode cpu i.e. 64 bit CPU. For more info type the following cat command to get complete info on your CPU:
cat /proc/cpuinfo
cat /proc/cpuinfo | more

How do I know if my Linux is 32 bit or 64 bit?

Now you know you have an AMD CPU that can run both 32bit and 64 bit operating systems. But, how do I know if my current kernel and Linux distro are 64-bit or 32-bit? Fear not, run the following command:
getconf LONG_BIT

The getconf command checks if the Linux kernel is 32 bit or 64 bit. The 64 means I am running 64 bit Linux kernel and Linux distro.

Other Linux command to check if I have a 32-bit or a 64-bit OS

Run the following uname command:
uname -i
For 64bit you will get x86_64 and i386 for 32bit Intel CPU.

A note about GUI method

Open your Linux distros, System Settings window, and select the Details:

Use the lshw command

Execute the following lshw command to list all info about CPU:
sudo lshw -c cpu
Sample outputs:

Источник

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

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?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux
Est. reading time 4 minutes

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:

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:

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:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

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:

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

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

Conclusion

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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

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

lshw -class processor

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:

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

Man, read the post! This shows how to find out if the KERNEL is a 64bit kernel and also if the CPU is 64bit. READ.

please read postings more down – this is not correct in any case too…

Yes. This is actually correct. The OP has a lot of confusing information about what the case will be if installed OS is 32 bit but CPU actually has 64 bit capabilities

Thanks for this quick information. It was really helpful .

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

Thanks a lot. Good One

getconf LONG_BIT
which returns either 32 or 64
says nothing about the cpu capabilities, just the os that is running. ( you can run 32bit os on 64bit capable chip, but not the other way arround) the ;
> cat /proc/cpuinfo
and looking for lm seems to tell you if it is capable of 64bit
and it also tells you the chip and model # which you can google and verify.

Thanks, this is the great post.

Bingo! Thanks a lot for the perfect answer!

Thanks a lot dude

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

That’s because you are running a 32bit kernel.

Thank U for Your Great post

Awesome! Exactly what i needed.
Good Job Man.

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?

You installed i386 (32bit arch) kernel on 64bit (lm) machine

That’s what I’m going to do too, cause nsviewer is 32bit and it gets buggy and eats too much proc time on 64 machine.

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

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

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.

# 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?

# getconf LONG_BIT
32

# 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 constant_tsc pni monitor ds_cpl est cid 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 est cid cx16 xtpr lahf_lm

and
# uname -a
Linux 2.6.15-1.2054_FC5smp #1 SMP Tue Mar 14 16:05:46 EST 2006 i686 i686 i386 GNU/Linux

very thankfull to all for very authorative answer

Thanks to all.
It’s very helpful.

# getconf LONG_BIT
it’s tell you whether you’re use 32-bit or 64-bit kernel not your proccessor.
32-bit kernel returns 32, even on 64-bit processor

This was very helpful.

Anyways i checked with cat /proc/cpuinfo and grep flags /proc/cpuinfo it returns the same thing though i am running it on32 bit operating system (ubuntu)

Anyways thanks a lot for useful information

very helpful …thank you guys

this really helped me, and i found i was running a 64 bit processor
cheers.

try these commands
file /bin/dd #file determine the file type
[ray@test]$lsb_release
LSB Version: :core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:desktop-3.1-ia32:desktop-3.1-noarch:desktop-3.2-ia32:desktop-3.2-noarch
[root@localhost

]# lsb_release
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarc

[ray@test]$ uname -m
it`s tell us whether we’re use 32-bit or 64-bit kernel
The Enterprise CPU support ia32bit and amd64bit currently.

Ray, those only show if you are running a 32/64 bit OS, not the processor info. 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.

cat /proc/cpuinfo |grep ” lm” will tell you if you have the lm flag, and thus if your processor is 64 bit.

file /bin/dd just shows you that dd is a 32 or 64 bit executable. It could be a 32 bit executable in a 64 bit OS or a 32 bit OS with either kernel as well. However, it’s unlikely, so this is a good test of what your OS is.

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.

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.

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.

An annoying issue for me is that my system outputs “unknown” when I try to ask about CPU info with “uname -p” command. Although “cat /proc/cpuinfo” and “dmesg | grep -i cpu” puttin’ out the correct things, “uname” won’t it at all.

Does anyone know how to make” uname” to tell me what i ask from?

> You need to run the less /proc/cpuinfo command to determine if CPU is 64 bit or not.
sorry, but this is not correct.
> flag: lm
This won’t help to find out if your CPU is able to run 64bit kernels or 64bit capable anymore.

Especially newer Intels / Xeons are still 64bit but there is no such easy way (/proc/cpuinfo flags or uname) to find out if it runs 64bit kernels or not (i.e. there is no lm (long mode)).

Best way in such cases is to run a google against the original CPU docs/specs or try a small live 64bit linux kernel to boot.

If i’m wrong and someone has a better way feel free to correct me.

Newer Intels / Xeons doest have the ‘lm” flag but are able to run 64bit kernels too.

This means to find out if a CPU is 64bit capable there is no such easy way.

You have to run a google against the CPU specs / docs or to try a 64bit system (i.e. a small live system from CD or USB) to boot.

uname just tells you what kind of arch the software (kernel) is – which might be independent from the CPU capabilities (many 64bit CPUS are still capable to run 32bit code) .

dmidecode -t 4 (as root)

Yes, dmidecode gives an additional option to find out if a CPU is 64-bit capable, but dmidecode is’nt right or working here on more or less environments / machines.

Additionaly man demidecode says:
“more often or not information contained in DMI tables is inaccurate, incomplete or wrong”
and
“…the presented information possibly unreliable”

This might have different reasons, from buggy or incomplete BIOS implementations, DMI tables to partly “incompatible” hardware . So i saw f.i. different results here just before and after a BIOS update…

But on most newer / modern (modular) servers from the main vendors the BIOS / DMI implementation seems to be working as expected as more and more of their management tools are depending from it.

Forget everything and just use in your shell window
lshv

If you dont have this try installing it (yum install lshv)
this utility will give you more than what you want to know 🙂

you can also get html report of your complete hardware info by typing:

lshv -html > report.html

afaik lshv uses DMI too – so it does not get more informations out then dmidecode or other described sources here – just brings it into some “nice” (may just overloaded in this scenario) HTML stuff). I assume that is usualy not that what peoples want if they want to script something…

Not at least: as dmidecode and other DMI-tools it works only if the kernel provides DMI access / drivers to the regarding hardware.

As i stated before – there is no reliable (!) way to find out if a CPU (which is not shown as 64bit capable by all these tools and commands) is NOT a 64bit capable one. dmidecode (DMI) is (afaik) the most reliable source on system side but not correct in each case.

Источник

Читайте также:  Splendid utility asus для windows 10 что это
Оцените статью