Create or reverse a hex dump of binary data.
low risk
xxd creates hex dumps of files showing both hex values and ASCII representation, and can reverse hex back to binary. Used for inspecting binary file formats, debugging network protocols, and examining any file at the byte level.
| Flag | Meaning |
|---|---|
-r --reverse | Reverse: convert hex dump back to binary |
-l --len | Stop after N bytes |
-s --seek | Start at offset |
-c --cols | Bytes per row (default: 16) |
xxd /usr/bin/ls | head -5View first few bytes of a binary (check magic bytes) · explain & risk-check →echo 'hello' | xxdHex dump of a string · explain & risk-check →xxd -l 16 /dev/urandomGenerate 16 random bytes as hex · explain & risk-check →xxd -r hex.txt > binary.outConvert hex dump back to binary · explain & risk-check →Use `xxd -l 4 file` to read just the first 4 bytes (magic number) — fast file type verification at the byte level. ELF binaries start with 7f454c46, PNG with 89504e47.
Reference text is hand-written and may be incomplete — check man xxd for your version. Test destructive commands on a non-production system first.