On my machine I get the following output when I run these commands:

$ echo foos > myfile
$ hexdump myfile
6f66 736f 000a

The output from hexdump is little-endian. Does this mean that my machine is little-endian, or does hexdump always use little-endian format?


2 Answers 2


The traditional BSD hexdump utility uses the platform's endianness, so the output you see means your machine is little-endian.

Use hexdump -C (or od -t x1) to get consistent byte-by-byte output irrespective of the platform's endianness.


From the manpage:

 -x      Two-byte hexadecimal display.  Display the input offset in hexa‐
         decimal, followed by eight, space separated, four column, zero-
         filled, two-byte quantities of input data, in hexadecimal, per


 If no format strings are specified, the default display is equivalent to
 specifying the -x option.

Your output is little-endian (least significant byte first), which is also the endianness of the x86 and x86_64 architectures, which you are probably using.

  • 6
    Is it just me, or does the man page not mention anywhere that it is treating the "two-byte quantities" as integers? I thought I was taking crazy pills... Commented Jun 14, 2017 at 21:41
  • @slashingweapon "two-byte quantity of input data" is uint16_t integer.
    – Ruslan
    Commented May 8, 2018 at 7:53
  • 3
    "Two bytes" is not the same as uint16_t on a little-endian system. Commented May 10, 2018 at 16:43
  • Furthermore, we should stop using this ambiguous term called "byte". If you meant 8-bit units, then "octet" would be precise.
    – ZeZNiQ
    Commented Jan 2, 2022 at 19:35
  • That ship has sailed, @ZeZNiQ. At this point, "byte" and "octet" are synonyms, and only rather old reference materials refer to "bytes" of any other size...
    – Mark Reed
    Commented Dec 4, 2023 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .