xxd

Create or reverse a hex dump of binary data.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

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.

Common flags
FlagMeaning
-r --reverseReverse: convert hex dump back to binary
-l --lenStop after N bytes
-s --seekStart at offset
-c --colsBytes per row (default: 16)
Examples
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 →
Pro tip

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.

Related
strings file base64
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man xxd for your version. Test destructive commands on a non-production system first.