Back to the command reference

xxd

FilesAdvanced In simulator In real Linux

Make a hex dump or reverse one

Name: xxd: a hex dump tool

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

xxd makes a hex dump: offsets on the left, hex bytes in the middle, printable characters on the right. -r turns a dump back into binary, which lets you "edit" binary files. It usually comes with vim.

Syntax

xxd [OPTION]... [FILE]

Common options

-l LENStop after N bytes
-s [+-]SEEKStart at byte SEEK (-SEEK counts from the end)
-c COLSCOLS bytes per line (16 by default)
-g BYTESGroup BYTES bytes together (2 by default)
-pPlain hex output
-rReverse a hex dump to binary
-uUpper-case hexadecimal
-bShow bits (0 and 1)
-iOutput a C array

Examples

  • $ xxd image.png | head

    Look at a file header

    Explain
  • $ echo hello | xxd -p

    Text to hex

    Explain

Related