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.
Best Answer
On Debian and derivatives,
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 runarmhf
on a 64-bit ARM CPU. It's even possible to have mostlyi386
binaries (so the primary architecture isi386
) on anamd64
kernel...