Thursday 18 April 2013

How to Check if a machine runs on 64 bit or 32 bit Processor/Linux OS?

                    
                 
Before answering above question we have to understand below points.
  1. We can run a 32-bit Operating system on a 64 bit processor/system.
  2. We can run a 64-bit operating system on a 64 bit processor/system.
  3. We cannot run a 64-bit operating system on a 32-bit processor/system.
  4. We can run a 32-bit operating system on a 32-bit processor/system.
Once we are clear about the above 4 points then we can see if our machine have a 64 bit processor or not.
How to check if my CPU is a 64-bit supported processor or not?
There are two commands to check if it’s a 64 bit processor or not
Option 1: use lscpu command to check if it supports multiple CPU operation modes(either 16, 32 or 64 bit mode).
as a normal/root user execute below command
lscpu | grep op-mode
Sample output on a 64-bit processor

rahul@rahul-desktop:~$ lscpu | grep op-mode
CPU op-mode(s): 32-bit,64-bit
Sample output on a 32-bit processor

rahul@rahul-desktop:~$ lscpu | grep op-mode
CPU op-mode(s): 32-bit
If you observe the first output will say that your CPU supports both 32-bit as well as 64 bit operating systems. This indicates that its 64-bit processor from our above 4 rules. But in the second machine it say’s only 32-bit CPU mode which indicates its a 32 bit processor.

Option 2: How to check if my Operating system is a 64-bit or 32-bit?
Before knowing about this you should know about i386, i486 etc naming convention.

What is difference between i386, i486, i586, and i686 OS?
They are the names given by software industry to some software’s for different Intel architectures. If we say i386, its Intel 80386 processor, also known as the i386, or just 386, was a 32-bit microprocessor introduced by Intel in 1985. If I say i486 it’s an Intel 80486, i586 it’s a 80586 and i686 its a 80686 processor. In short they are called as x86 family which are of 32 bit processor. And for 64 bit OS you will get x86_64.
rahul@rahul-desktop:~$ lscpu | grep -i arch
Architecture:          i686

Sample output for 64 bit OS
rahul@rahul-desktop:~$ getconf LONG_BIT
64

Sample output for 32 bit OS
rahul@rahul-desktop:~$ getconf LONG_BIT
32
 
rahul@rahul-desktop:~$ uname -m
i686
rahul@rahul-desktop:~$ uname -p
i686

No comments:

Post a Comment