How to View Binary Files Using the od Command in Linux

When you attempt to open a compiled executable binary file (like a .o or an a.out file) using a standard text reader like cat or nano, your terminal will instantly explode with chaotic gibberish and unreadable character blocks. This happens because standard text editors are mathematically hard-coded to interpret raw bytes as ASCII letters. To force the Linux kernel to bypass the ASCII translation layer and dump the absolute, raw mathematical data directly to your screen for forensic analysis, you must use the od (Octal Dump) command.

How the od Command Works

The od command is a low-level diagnostic tool designed for reverse engineers and systems programmers. Instead of trying to render the bytes into human-readable letters, it takes the raw binary zeros and ones stored on the hard drive platter and mathematically converts them into strict Octal (base-8) or Hexadecimal (base-16) numbers.

To execute a standard octal dump, simply type the command followed by the target binary file:

od my_compiled_program.bin

The system will output a massive grid of data that looks like this:

0000000 042577 043114 001001 000000 000000 000000 000000 000000
0000020 000002 000076 000001 000000 011030 000400 000000 000000

The column on the absolute far left (e.g., 0000000, 0000020) represents the specific byte offset (the exact physical location of the data within the file). The remaining columns are the raw 16-bit octal values.

Extracting Hexadecimal and ASCII Data

While the default base-8 octal output is historically accurate, modern forensic analysts almost exclusively use base-16 Hexadecimal. The od command allows you to aggressively reformat the output using specific flags.

To force the system to dump the file in standard Hexadecimal format, use the -t x1 (Type Hexadecimal, 1-byte chunks) flag:

od -t x1 my_compiled_program.bin

The terminal will instantly re-render the data grid into clean, standard hex pairs (e.g., 7f 45 4c 46).

If you want to view the raw hexadecimal data while simultaneously attempting to extract any hidden, readable ASCII strings (like a hard-coded password or a URL buried deep inside the binary), you can use the -c (Character) flag alongside the hexadecimal flag:

od -t x1 -c my_compiled_program.bin

This prints a highly complex, interleaved grid where every single line of hexadecimal pairs is immediately followed by a line attempting to translate those exact pairs into readable ASCII characters, allowing you to manually map the mathematical data to the underlying text.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.