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

9

3

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.

Sagar R. Kothari

Posted 2010-08-10T07:15:33.813

Reputation: 4 267

But what about OSX ? – Sagar R. Kothari – 2011-06-11T06:41:26.923

Answers

5

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)

Maciej Kucharz

Posted 2010-08-10T07:15:33.813

Reputation: 198

1Or just "uname -p" which returns results like i386, x86_64, amd64 :) – Janne Pikkarainen – 2010-08-10T08:02:47.180

what's i386 ? uname -p works but I don't understand i386 – Sagar R. Kothari – 2010-08-10T08:12:12.660

1Keep in mind that on OSX, even if you have a x86_64 CPU, (some of) the kernel might run in 32 bit. This is true for the early 2008 MacBook (4,1) for example. – trolle3000 – 2010-08-10T08:17:10.543

@sugar, i386 is a 32bit CPU architecture, and x86_64 is a 64-bit architecture. – trolle3000 – 2010-08-10T08:18:17.977

1@sugar you may also see in some places i486, i586 or i686 these are also 32bit but include more instructions. – AndrejaKo – 2010-08-10T08:46:07.897

why you forget about Windows..? – Piotr Kula – 2012-05-21T15:19:38.597

7

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

paradroid

Posted 2010-08-10T07:15:33.813

Reputation: 20 970

just what i needed – Piotr Kula – 2012-05-21T15:19:08.690

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)

peter

Posted 2010-08-10T07:15:33.813

Reputation: 184

ia64 is for Itanium processors which are completely different architecture and are not part of x86 family. They can run x86 programs but their 64 bit mode is basically completely different from x86 and requires different compilers and whole low-level programming. Amd64 is named after AMD because they made 64bit extensions to x86 instruction set. Their processors are still x86 but can work with 64bits and they are much more related to 32bit x86 than itanium. – AndrejaKo – 2010-08-10T08:50:58.407

2

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.

Sam Liao

Posted 2010-08-10T07:15:33.813

Reputation: 386

2

@paradroid - Thanks for the brainstorm ^^

I now use this for a Java program I distribute which needs Windows users to utilize javac. This script checks their architecture and opens the download to the proper version of JDK in their default browser...

@echo off

Title Dragon's JDK Downloader - Runedev Script Compiler

goto menu
:menu
echo.
echo What would you like to do?
echo.
echo 1. Download JDK?
echo 2. Compile Scripts?
echo 3. Quit
echo.

:choice
set /P C=1,2,3?
if "%C%"=="3" goto quit
if "%C%"=="2" goto compile
if "%C%"=="1" goto download
goto choice

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

:x86
START http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u23-windows-i586.exe?BundledLineItemUUID=q9.J_hCupJ8AAAEsXThZDfyg&OrderID=zHCJ_hCujC0AAAEsUjhZDfyg&ProductID=_omJ_hCwMp4AAAEsQIMcKluK&FileName=/jdk-6u23-windows-i586.exe
goto :eof

:x64
START http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u23-windows-x64.exe?BundledLineItemUUID=CMyJ_hCu.vEAAAEsWu9ZDfyf&OrderID=RZ.J_hCuAVkAAAEsUO9ZDfyf&ProductID=ZUuJ_hCwEmwAAAEsOoMcKluK&FileName=/jdk-6u23-windows-x64.exe
goto :eof

:compile
SET cc=javac
SET cflags=
SET scripts=Scripts
SET scriptspre=%scripts%\Precompiled
SET jarpathfile=Settings\path.txt

IF NOT EXIST "%jarpathfile%" (
   ECHO Path file does not exist. Please run Runedev and try again.
   GOTO menu
)

FOR /F "delims=" %%G IN (%jarpathfile%) DO SET jarpath=%%G

CALL FindJDK.bat

IF NOT EXIST %scripts%\*.java (
   ECHO No .java script source files found.
   GOTO menu
)

ECHO Compiling scripts
ECHO. > "%scripts%\.class"
DEL /F /Q "%scripts%\*.class" > NUL
"%cc%" %cflags% -cp "%jarpath%" %scripts%\*.java

:end
PAUSE
EXIT

:quit
exit
:end

Dragon

Posted 2010-08-10T07:15:33.813

Reputation: 21