Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

bootinfo for AIX:

...shows whether the hardware in use is 32-bit or 64-bit.

What command/utility for Linux would do this job?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

There are several possible answers depending on what exactly you want to know (I don't know which one AIX's bootinfo corresponds to).

  • You can see whether the CPU is 64-bit, 32-bit, or capable of both by checking the flags line in /proc/cpuinfo. You have to know the possible flags on your architecture family. For example, on i386/amd64 platforms, the lm flag identifies amd64-capable CPUs (CPUs that don't have that flag are i386-only).

  • You can see whether the kernel is 32-bit or 64-bit by querying the architecture with uname -m. For example, i[3456]86 is are 32-bit while x86_64 is 64-bit. Note that on several architectures, a 64-bit kernel can run 32-bit userland programs, so even if the uname -m shows a 64-bit kernel, there is no guarantee that 64-bit libraries will be available.

  • You can see what is available in userland by querying the LSB support with the lsb_release command. More precisely, lsb-release -s prints a :-separated list of supported LSB features. Each feature has the formm module-*version*-architecture. For example, availability of an ix86 C library is indicated by core-2.0-ia32, while core-2.0-amd64 is the analog for amd64. Not every distribution declares all the available LSB modules though, so more may be available than is detectable in this way.

  • You can find out the preferred word size for development (assuming a C compiler is available) by compiling a 5-line C program that prints sizeof(void*) or sizeof(size_t).

share|improve this answer

Usually uname -m should do the trick, as should arch.

The output of both of these commands will tell you the architecture for which the kernel was built. Whether this is 32 or 64 bit is usually pretty clear (x86_64 and ia64 are two possible 64-bit architectures). However, note that you could have a 32-bit kernel while running on 64-bit hardware. If you really want to know about the hardware try looking at either

less /proc/cpuinfo

if the "flags" line has 'lm' in it, then it is 64 bit.

Or, if you have lshw

lshw -class processor

and look at the "width" line.

For both of these options, grep can be employed to quickly get the answer without looking at the output.

share|improve this answer
2  
More precisely, uname -m tells you the architecture for which the kernel was built. For example there are a few systems out there with an amd64 kernel but a 32-bit userland. –  Gilles Oct 11 '10 at 18:57
    
Excellent point Gilles. I updated my answer accordingly. –  Steven D Oct 11 '10 at 19:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.