23

what would be a command to run in different distros?

webwesen
  • 935
  • 4
  • 13
  • 21

10 Answers10

37

"uname -m" is the command you're looking for. You can run both 32bit and 64bit on modern intel and AMD processors, so "uname -p" is not going to help you (in addition it mostly doesn't work these days, this here core2 thinks the response to "uname -p" is "unknown").

Looking for existence of /usr/lib64 (as has been suggested) is not going to help you either, since some hardware and system related packages will install both 32bit and 64bit libraries to be on the safe side. On my (debian) system the fakeroot package does just that.

As for the output of "uname -m", if it's i386 or i686 it's 32bit, if it's x86_64 (or alpha, or ia64 or some other 64bit architecture I've never seen :) it's 64bit.

(as a fun aside, my 64bit FreeBSD server returns "amd64", which might be a bit strange for an intel quadcore but totally understandable if you know the history of the x86 64bit architecture)

flinkflonk
  • 654
  • 4
  • 5
  • 1
    does this tell you the installation architecture or the actual CPU architecture. For example, if you installed 32-bit OS on 64bit cpu, would this return i686 or x86_64? – monkut Jul 19 '11 at 08:56
15

uname -a and look for x86_64. If you want to know if your CPU can handle 64bit, cat /proc/cpuinfo and look for lm within the flags.

kashani
  • 3,922
  • 18
  • 18
6

$> getconf LONG_BIT Answer: 32 or 64.

Dennis Winter
  • 448
  • 2
  • 7
  • 15
6

for RedHat/CentOS:

$ uname -a
Linux cs-centos 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686 athlon i386 GNU/Linux

32-bit

  • i686 and/or i386

64-bit

  • would have x86_64 in uname -a output
webwesen
  • 935
  • 4
  • 13
  • 21
6

Just to confuse things, you can run a 64bit kernel with a 32bit userland, which is what I'm doing. In this case, uname -m returns x86_64 but I don't have any 64bit libraries installed so most 64bit programs won't run.

So once you check uname, you need to look for /lib64/ld-linux-x86-64.so.2, /lib64/libc-2.7.so and /lib/ld-linux.so.2, /lib/libc-2.7.so to see whether 64bit and 32bit libraries are available. And to really make sure, run those files and see if they execute correctly.

Another useful piece of information is the output of lsb_release -a which is cross-distro and will report what architecture-specific LSB modules are available.

TRS-80
  • 2,564
  • 17
  • 15
2

Another way to do it is to ask perl what compiler said the size of a long integer is:

$ perl -MConfig -e 'print $Config{longsize}*8 . "\n";'
64

vs.

$ perl -MConfig -e 'print $Config{longsize}*8 . "\n";'
32

Or, if you've got gcc installed, the same in C:

$ cat > bits.c <<EOC
> #include <stdlib.h>
> #include <stdio.h>
> 
> int main(void) {
>    printf("%d\n", (int)sizeof(long)*8);
> 
>    exit(0);
> }
> EOC
$ gcc -Wall -o bits bits.c
$ ./bits
64

vs.

[...]
> EOC
$ gcc -Wall -o bits bits.c
$ ./bits
32

:-)

asjo
  • 1,228
  • 8
  • 6
1

As a duplicate of :

Linux + how to verify linux version 32 Bit or 64 Bit

uname -m will only give you the running 'arch'/architecture of the kernel. It will NOT tell you if your are running a 32 bits GNU/Linux distribution on a 64bits capable CPU.

To know your CPU capability:

 cat /proc/cpuinfo

The 'LM' flag should be present in 64bits systems as it represent 'LONG MODE' (64bit Extensions, AMD’s AMD64 or Intel’s EM64T).

CloudWeavers
  • 2,511
  • 1
  • 14
  • 17
0

Brad Gilbert's command had a perl bug. I've fixed it and the below command works: cat /proc/cpuinfo | grep ^flags | perl -e '$=<>;print ($?"x86_64\n":"not x86_64\n")'

0
$ uname -p

x86_64
Matt Simmons
  • 20,218
  • 10
  • 67
  • 114
0

If you have /usr/lib64 you're running x86_64..

Cube_Zombie
  • 169
  • 1
  • 5