Session and utilities

The od command

Dumps a file in octal or other formats, to inspect raw data.

Syntax

od [opciones] [archivo...]Try it in the terminal →

Most useful options

-A <base>Offset format: d decimal, o octal, x hexadecimal or n for no offsets.
-t <tipo>Output format: x1 hexadecimal per byte, o1 octal per byte, c characters. Several can be given.
-cShows printable characters and escape sequences, such as \n. It is the same as -t c.
-xHexadecimal in 2-byte units. It is the same as -t x2, not single bytes.
-j <bytes>Skips that many bytes at the start of the input.
-N <bytes>Processes only that many bytes of input.
-w [bytes]Bytes per output line. Without a value it uses 32; the default is 16.
-vShows every line, including repeated ones. Without it, repeated lines are replaced by an asterisk.

Copy-ready examples

$ echo hola | od -cshows each character; the newline appears as \n.

Example output

0000000   h   o   l   a  \n
0000005
$ echo hola | od -t x1one byte per column, in hexadecimal.

Example output

0000000 68 6f 6c 61 0a
0000005
$ echo hola | od -A x -t x1z -voffsets in hexadecimal and the text at the end of the line, with no asterisks.

Example output

000000 68 6f 6c 61 0a                                   >hola.<
000005
$ printf 'abcdefgh' | od -j 2 -N 3 -cskips two bytes and shows only three.

Example output

0000002   c   d   e
0000005
$ od -A n -t x1 -N 4 imagen.pngfirst four bytes without offsets. The PNG signature starts with 89 50 4e 47.

Example output

 89 50 4e 47

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
od: invalid option -- 'Q'od has no -Q option. The options are listed in od --help.Write the correct option or check od --help.
od: nofile: No such file or directoryThe file does not exist or the name is mistyped.List the folder with ls and copy the exact name.

Typical mistakes

  • By default od prints 2-byte octal units, not single bytes: use -t x1 or -t o1 to see each byte.
  • With -c, non-printable bytes show as escape sequences, such as \n, not as a dot as xxd does.
  • An asterisk in the output means that line repeats; -v shows every line, even repeated ones.

Differences from similar commands

  • xxd: shows hexadecimal with a text column and can revert the dump. od dumps in octal by default and cannot revert it.
  • hexdump: with -C it shows hexadecimal and the text between | bars. od, by default, shows octal numbers without that column.

Related commands

FAQ

What does the number on the left mean?

It is the offset: the position of the first byte of the line within the file. By default it is octal; with -A d or -A x it switches to decimal or hexadecimal.

How do I read a binary from a specific point?

With -j, which skips bytes at the start, and -N, which limits how many are read. od -j 1024 -N 64 file.bin shows 64 bytes starting at byte 1024.

How do I see only the bytes, without offsets?

With -A n: od -A n -t x1 file.bin shows the bytes in hexadecimal and no position numbers.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course