hd
Display file contents in hexadecimal format
TLDR
View documentation for the original command
SYNOPSIS
hd [-b|-C|-n NUM|-N NUM|-s[LEN]|-t TYPE|-v|-w NUM|-x] [FILE...] | hd --help | hd --version
PARAMETERS
-b, --bits
Format output in bits (8-bit bytes)
-C, --color[=WHEN]
Colorize output; WHEN is always, never, or auto (default always)
--help
Display usage help and exit
-n, --skip-bytes=NUM
Skip NUM bytes from file start
-N, --skip-bytes-end=NUM
Skip NUM bytes from file end
-s, --strings[=LEN]
Output strings of at least LEN chars (default 4)
-t, --format=TYPE
Output format: hex (default), octal, loop, raw, string, bits
--version
Output version info and exit
-w, --width=NUM
Bytes per line (default 16)
-x, --hex-escape
Use hex escapes (\xHH) for non-printables
DESCRIPTION
The hd command from the util-linux package displays file contents in hexadecimal and ASCII formats, making it ideal for inspecting binary data, debugging files, or analyzing mixed text-binary content.
By default, it outputs 16 bytes per line: a decimal offset, hexadecimal byte values, and an ASCII panel where non-printable characters appear as dots (·). It reads from files or standard input, streaming large files efficiently.
Key features include customizable output formats (hex, octal, raw, strings, bits), adjustable line width, byte skipping from start/end, string extraction, hex escapes for non-printables, and optional colorization for enhanced readability on terminals.
Common uses: reverse engineering executables, verifying data integrity, forensic analysis, or scripting to parse binary protocols. Simpler than hexdump, it prioritizes speed and clarity for everyday tasks.
Invoke without arguments for help/version. Supports multiple files, processing each sequentially.
CAVEATS
No progress indicator for huge files; color may not work in non-terminals; stdin treated as single file if mixed with args.
EXAMPLES
hd file.bin
hd -w32 -C /dev/zero
hd -t string -s8 log.txt
hd -n1024 image.jpg | head
OUTPUT FORMATS
hex: Offset + hex bytes + ASCII
raw: Hex bytes only
string: Printable strings
bits: Binary bit view
HISTORY
Introduced in util-linux 2.29 (2016) by Karel Zak; evolved from coreutils tools for simpler hex viewing.


