Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Viewing and Searching Files

Linux od command

Reference for the Linux od command: dump file bytes as octal, hex, decimal or characters, choose word sizes and offsets, and read the output correctly.

od ("octal dump") prints the exact bytes of a file in a readable form: octal by default, or hex, decimal, floating point or characters. It is part of POSIX and coreutils, so it exists on nearly every system, even where xxd and hexdump are missing.

Use it to find a hidden carriage return, check a file's encoding, inspect the magic number of a binary, or see what a program really wrote.

Terminal
od [OPTION]... [FILE]...

Try it

Bash Characters and hex

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Word sizes, offsets and repeated lines

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
od [-A RADIX] [-t TYPE]... [-j SKIP] [-N COUNT] [-w[BYTES]] [-v] [FILE]...
Option Description
-A RADIX Offset base: d decimal, o octal (default), x hex, n none.
-t TYPE Output format: a named characters, c characters, d signed, u unsigned, o octal, x hex, f float; add a size such as x1, u2, d4, f8.
-c Same as -t c.
-x, -o, -d Old shortcuts for 2-byte hex, octal and unsigned decimal words.
-j N, --skip-bytes=N Skip N input bytes first.
-N N, --read-bytes=N Stop after N bytes.
-w[N] Bytes per output line (default 16).
-v Do not collapse identical lines into *.
-S[N] Print strings of at least N printable characters (like strings).

Returns: 0 on success; non-zero if an input file cannot be read.

Usage notes

  • Default output is 2-byte octal words, which surprises people. For a byte view write -t x1, or -A x -t x1z to add a printable column on the right.
  • Byte order. Multi-byte types (u2, u4) use the machine's endianness, little-endian on x86 and ARM Linux. Hex bytes with x1 are always in file order.
  • -An removes the offset column, which makes the output easy to feed to other tools or compare in tests.
  • Repeated lines are replaced by a single * line. Use -v when you must see everything.
  • The last line of output is the total byte count in the chosen radix, not a data row. With -An it is omitted.
  • Escapes in -c: \n, \t, \r, \0 appear as such; other non-printable bytes appear as three-digit octal.
  • Quick checks: od -c file | head to spot CRLF line endings; od -An -t x1 -N 4 for a magic number.
  • xxd and hexdump have friendlier default layouts but are not always installed.