How to check whether my OS is 64-bit or 32-bit?

What is the best way to determine whether my OS is 64-bit or 32-bit ?

Assume that, I directly on some os & I am going to install a software on it. But how to determine, whether OS is 32-bit or 64-bit,

OS may be anything, like

  • windows xp
  • vista
  • windows 7
  • os x leopard
  • os x snow leopard
  • Red hat linux

What I mean is - what is the best & common way to determine whether os is 64-bit or 32-bit? I mean, I am talking in general. I haven't installed os on someone's machine & if I tell you to determine its OS base - 64 or 32 ? then what would you do ?

Thanks in advance for sharing your knowledge. Sugar.


Solution 1:

In many Unix-like systems you can type in:

uname -a

For FreeBSD it looks like:

FreeBSD whiplash 8.0-STABLE FreeBSD 8.0-STABLE #1: 
Tue Mar  9 15:38:19 CET 2010     root@beast:/usr/obj/usr/src/sys/WHIPLASH  amd64

(amd64 means that this kernel is 64-bit)

For Linux:

Linux softy.vm 2.6.18-128.el5 #1 SMP 
Wed Jan 21 10:44:23 EST 2009 i686 athlon i386 GNU/Linux

(i386 means that this kernel is 32-bit)

For MacOSX:

Darwin iMac.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009;
root:xnu 1456.1.25~1/RELEASE_X86_64 x86_64

(x86_64 means that this kernel is 64-bit)

Solution 2:

If you were to do any actions using CMD scripting in Windows, you could start the batch file something like this:

@echo off

if %PROCESSOR_ARCHITECTURE% == x86 (
goto :x86
) else (
goto :x64
)

:x86
start "foo.exe"
goto :eof

:x64
start "bar.exe"
goto :eof

Solution 3:

Under Windows:

The GUI Way

  1. Press Win+R to open the Run... Dialog
  2. Enter winmsd
  3. Look for row Processor or System type

If they begin with x86 you have 32-Bit otherwise you have 64-Bit

Using cmd.exe
Enter SET PROCESSOR_ARCHITECTURE
x86 means 32-Bit, otherwise it's 64-Bit

Using Powershell
Enter $env:PROCESSOR_ARCHITECTURE
Meaning is the same as with using cmd.exe

Beware
There are two different types of 64-Bit architectures.
One is AMD64 for x64 the other is ia64 for Itanium (not sure this value is exactly like that, never worked with any of them)

Solution 4:

Stupid ways for Linux:

  1. To identify the kernel, cat /proc/kallsyms, check whether the symbols for kernel is 32 bits wide or 64 bits wide. Then you will know the kernel is 32 bits or 64bits.

  2. For the user application, just run: $file /bin/ls To check whether the ls command is 32 bits or 64bits, since the os may contain both 32bits and 64bits applications, this may not be wrong.