Architecture detection in Linux

To see if Linux is compiled with 64 bit support and can fully take advantage of your 64 bit CPU, you can use the information contained in /proc and uname.

The following script does the job:

#!/bin/bash

echo -n "Linux: "
if test "`uname -m | grep _64 | wc -l`" -eq 0; then
    echo -n "32 bits. "
else
    echo -n "64 bits. "
fi

echo -n "CPU: "
if test "`grep flags /proc/cpuinfo | grep ' lm' | wc -l`" -eq 0; then
    echo "32 bits."
else
    echo "64 bits."
fi

If Linux is compiled with 64 bit support and you have a 64 bit CPU, you will see the following output:

Linux: 64 bits. CPU: 64 bits.