lscpu
The lscpu
command shows (among other things):
Byte Order: Little Endian
Systems this is known to work on
- CentOS 6
- Ubuntu (12.04, 12.10, 13.04, 13.10, 14.04)
- Fedora (17,18,19)
- ArchLinux 2012+
- Linux Mint Debian (therefore assuming Debian testing as well).
Systems this is known to not work on
- Fedora 14
- CentOS 5 (assuming RHEL5 because of this)
Why the apparent differences across distros?
After much digging I found out why. It looks like version util-linux version 2.19 was the first version that included the feature where lscpu
shows you the output reporting your system's Endianness.
As a test I compiled both version 2.18 and 2.19 on my Fedora 14 system and the output below shows the differences:
util-linux 2.18
$ util-linux-ng-2.18/sys-utils/lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 4
Thread(s) per core: 2
Core(s) per socket: 2
CPU socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 37
Stepping: 5
CPU MHz: 1199.000
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3
util-linux 2.19
$ util-linux-2.19/sys-utils/lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
CPU socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 37
Stepping: 5
CPU MHz: 2667.000
BogoMIPS: 5320.02
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3
The above versions were downloaded from the kernel.org website.
od
method? It's simple and works everywhere. It's what I thought of before reading the body of your question.lscpu
method is more what I would come to expect.od
approach should work on most open systems, not only linux, which would be the case with usinglscpu
. So what is "best" depends on the circumstances.