Does anyone know of a command that reports whether a system is Big Endian or Little Endian, or is the best option a technique like this using Perl or a string of commands?Perl# little$ perl -MConfig -e 'print $Config{byteorder}\n;'12345678# big$ perl -MConfig -e 'print $Config{byteorder}\n;'87654321od | awk# little$ echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}'1# big$ echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}'0ReferencesPerl Config documentation - byteorder
Is there a system command, in Linux, that reports the endianness?
cpu architecture
lscpuThe lscpu command shows (among other things):Byte Order:            Little EndianSystems this is known to work onCentOS 6Ubuntu (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 onFedora 14CentOS 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_64CPU op-mode(s):        32-bit, 64-bitCPU(s):                4Thread(s) per core:    2Core(s) per socket:    2CPU socket(s):         1NUMA node(s):          1Vendor ID:             GenuineIntelCPU family:            6Model:                 37Stepping:              5CPU MHz:               1199.000Virtualization:        VT-xL1d cache:             32KL1i cache:             32KL2 cache:              256KL3 cache:              3072KNUMA node0 CPU(s):     0-3util-linux 2.19$ util-linux-2.19/sys-utils/lscpu Architecture:          x86_64CPU op-mode(s):        32-bit, 64-bitByte Order:            Little EndianCPU(s):                4On-line CPU(s) list:   0-3Thread(s) per core:    2Core(s) per socket:    2CPU socket(s):         1NUMA node(s):          1Vendor ID:             GenuineIntelCPU family:            6Model:                 37Stepping:              5CPU MHz:               2667.000BogoMIPS:              5320.02Virtualization:        VT-xL1d cache:             32KL1i cache:             32KL2 cache:              256KL3 cache:              3072KNUMA node0 CPU(s):     0-3The above versions were downloaded from the kernel.org website.util-linux-ng-2.18.tar.bz2util-linux-2.19.tar.gz