Operating System - Linux
1753427 Members
4759 Online
108793 Solutions
New Discussion

Re: How to know 64 bit or 32 bit

 
SOLVED
Go to solution
CA1490051
Frequent Advisor

How to know 64 bit or 32 bit

Hi all,

Can i know how to find out a HP-UX machine is 32 bit or a 64 bit machine. Is there any command for that.

Even if it is not a HP machine can i write a code snippet to find out whether i am using 32 bit machine or a 64 bit machine.

thanks in advance
Vikram
6 REPLIES 6
Oviwan
Honored Contributor
Solution

Re: How to know 64 bit or 32 bit

Hey

type:
$getconf KERNEL_BITS

output will be 32 or 64

Regards
Anshumali
Esteemed Contributor

Re: How to know 64 bit or 32 bit

Hi,

You can use
getconf KERNEL_BITS
it will give you the O/P which you need.....

Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
James R. Ferguson
Acclaimed Contributor

Re: How to know 64 bit or 32 bit

Hi Vikram:

# getconf KERNEL_BITS

...will tell you the "bitness" of your current kernel, e.g. "64"

# getconf HW_CPU_SUPP_BITS

...will tell you the "bitness" your hardware will support, e.g. "32/64"

# file filename

...will return:

"ELF-64 executable object file - PA-RISC 2.0 (LP64)" for a 64bit codefile, otherwise something like:

"PA-RISC1.1 shared executable" for a 32bit one.

Regards!

...JRF...
Robert-Jan Goossens
Honored Contributor

Re: How to know 64 bit or 32 bit

Hi Vikram,
---
Even if it is not a HP machine can i write a code snippet to find out whether i am using 32 bit machine or a 64 bit machine.
---

You mean if is not hpux.

Linux
# getconf LONG_BIT
32

AIX
# bootinfo -K
64

Solaris
# isainfo -kv
64-bit sparcv9 kernel modules

Regards,
Robert-Jan
CA1490051
Frequent Advisor

Re: How to know 64 bit or 32 bit

Hi every one

Thank you very much for the reply.

This definitely solved my problem. But one thing i want to ask here for curiosity.

Can i write a code in C to tell this

for ex- to know a machine is little endian or big endian i can write like this.

union {
int Var;
char One;
}endian;

main ()
{
endian end;
end.Var = 0x01;
printf("%c",end.One);
}

thanks and regards
Vikram
Dennis Handly
Acclaimed Contributor

Re: How to know 64 bit or 32 bit

>Can I write a code in C to tell this

You can only write a program to tell what size the current program is, not the kernel.

For HP-UX, you could test a define:
#ifdef __LP64__

Or for general LP64 machines:
#include <stdio.h>
int main() {
    printf("size of void*: %d\n", (int)sizeof(void*));
    return 0;
}