I'm trying to write a script which will determine actions based on the architecture of the machine. I already use uname -m to gather the architecture line, however I do not know how many ARM architectures there are, nor do I know whether one is armhf, armel, or arm64.

As this is required for this script to determine whether portions of the script can be run or not, I am trying to find a simple way to determine if the architecture is armhf, armel or arm64. Is there any one-liner or simple command that can be used to output either armhf, armel, or arm64?

The script is specifically written for Debian and Ubuntu systems, and I am tagging as such with this in mind (it quits automatically if you aren't on one of those distros, but this could be applied in a much wider way as well if the command(s) exist)

EDIT: Recently learned that armel is dead, and arm64 software builders (PPA or virtual based) aren't the most stable. So I have a wildcard search finding arm* and assuming armhf, but it's still necessary to figure out a one liner that returns one of the three - whether it's a Ubuntu/Debian command or a kernel call or something.

  • You might be better off parsing /proc/config.gz if it is there. – umeboshi Jan 26 '15 at 16:41
  • 1
    Why do you say that "armel is dead" ? – Grodriguez May 16 '16 at 9:25

On Debian and derivatives,

dpkg --print-architecture

will output the primary architecture of the machine it's run on. This will be armhf on a machine running 32-bit ARM Debian or Ubuntu (or a derivative), arm64 on a machine running 64-bit ARM.

Note that the running architecture may be different from the hardware architecture or even the kernel architecture. It's possible to run i386 Debian on a 64-bit Intel or AMD CPU, and I believe it's possible to run armhf on a 64-bit ARM CPU. It's even possible to have mostly i386 binaries (so the primary architecture is i386) on an amd64 kernel...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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