od
Dump file contents in various formats
TLDR
Display file using default settings: octal format, 8 bytes per line, byte offsets in octal, and duplicate lines replaced with *
Display file in verbose mode, i.e. without replacing duplicate lines with *
Display file in hexadecimal format (2-byte units), with byte offsets in decimal format
Display file in hexadecimal format (1-byte units), and 4 bytes per line
Display file in hexadecimal format along with its character representation, and do not print byte offsets
Read only 100 bytes of a file starting from the 500th byte
SYNOPSIS
od [OPTION]... [FILE]...
od [-abcdfiloOsSxX]... [FILE] [[+]OFFSET[.][bB]]
PARAMETERS
-A RADIX, --address-radix=RADIX
Address base: decimal, octal, xex, none
-j BYTES, --skip-bytes=BYTES
Skip first BYTES input bytes
-N BYTES, --read-bytes=BYTES
Limit output to BYTES input bytes
-S BYTES, --strings[=BYTES]
Find printable strings of at least BYTES chars
-t TYPE, --format=TYPE
Select output format (e.g. a, c, d
-T BYTES, --width[=BYTES]
Output width in bytes per line
-v, --output-duplicates
Show all input data, do not use * for repeats
-w BYTES
Input block size (GNU extension)
--traditional
Use traditional format
-b
Octal bytes (-t o1)
-c
ASCII chars (-t c)
-d
Unsigned decimal words (-t u2)
-f
Floats (-t fF)
-i
Signed decimal words (-t d2)
-o
Octal words (-t o2)
-s
Signed decimal words (-t s2)
-x
Hex words (-t x2)
-X
Hex words uppercase (-t xC)
DESCRIPTION
od, short for 'octal dump', is a Unix/Linux command-line utility that displays file contents or standard input in various formats including octal, decimal, hexadecimal, ASCII characters, and floating-point numbers. It excels at examining binary data where text viewers fail, such as executables, images, or raw device files.
By default, od outputs data as two-byte octal words with octal byte addresses. Options allow customization: specify output radix for addresses, skip initial bytes, limit bytes read, set output width, or choose formats like hex (-x) or chars (-c). It supports both POSIX traditional options (e.g., -bcdfilosxX) and GNU long options (e.g., --format).
Typical uses include debugging binary protocols, viewing file headers (e.g., od -N 64 file for first 64 bytes), or converting data representations. Unlike hexdump, od is more portable and lightweight, adhering closely to POSIX standards. It's included in GNU coreutils and available on all major Unix-like systems.
For large files, combine with -N to avoid overwhelming output. An optional trailing offset lets you start dumping midway: od -t x1 file +16 skips first 16 bytes in hex.
FORMAT SPECIFIERS
For -t TYPE:
c: chars; d[N]: signed dec (N=1,2,4,8 bytes); u[N]: unsigned dec; f[N]: float; o[N]: octal; x[N], X[N]: hex (lower/upper); a: strings.
EXAMPLES
od -t x1 file: hex bytes.
od -c -N 20 /bin/ls: first 20 chars.
od -j 8 -N 16 -t d4 image.raw: 4-byte decimals starting byte 8.
HISTORY
Originated in Version 7 Unix (1979) by AT&T; standardized in POSIX.1-1992. GNU coreutils version enhances with long options and more formats since 1990s.


