How To Check If A Linux System Is 32 bit Or 64 Bit

Check If A Linux System Is 32 bit Or 64 Bit

5 Responses

  1. Stephane Chauveau says:

    Another easy way is to check at the actual size of the addresses for instance by looking in /proc/self/maps

    Be aware that the addresses of the application are typically small (so within the the 32 bit boundary) so it is better to look at the address of a shared library. The stack is also a good choice because it is typically located at the far end of the available address range.

    cat /proc/self/maps | grep stack
    7fffeaeb4000-7fffeaed5000 rw-p 00000000 00:00 0 [stack]

    In that example, we see that the stack of the ‘cat’ process starts at 0x7fffeaeb4000 which is obviously a 64 bit address (it contains more than 8 hexadecimal characters).

    Remark: 0x7fffeaeb4000 is actually a 48bit address because this is the current upper limit for all addresses on the ’64bit’ Intel processors.

    There is also a vsyscall entry in the maps files. That one looks like a true 64 address range but I do not know its purpose and if it is present on all Linux systems:

    cat /proc/self/maps | grep vsyscall
    ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

  2. C138 says:

    “So, this article may not useful for everyone out there”
    Not really 😉
    Since it’s possibe to install a 32 bits “logical” system on a 64bits “physical” architecture, it is worth saying that several commands are useful to detect your real architecture (while others are “lying”…)
    Your initial statement is right : “detecting the **installed** linux OS
    but this is note the same as “detecting your real architecture”.
    On this point, system commands are not useful, but asking for low lewel information (/proc/cpuinfo) is the (always) right way.

  3. Chris says:

    Most of these will only work on intel architectures. If “uname -m” returns s390 or sparc you still don’t know 32 or 64.

  4. WB says:

    None of this method is actually really correct.

    Use this: getconf LONG_BIT

    Quick and easy.

    Other methods, are not portable, only tell you about the CPU capabilities or kernel, but not what you are actually running in user space, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.