How to View Binary Files Using the od Command in Linux

When you attempt to open a massive binary file (such as a compiled executable program or an image file) in a standard Linux text editor like nano or vim, the terminal will instantly crash or output thousands of lines of chaotic, unreadable gibberish. Text editors are designed to read standard ASCII characters, not raw binary machine code. To mathematically bypass the text renderer and force the Linux kernel to dump the raw, unadulterated hexadecimal or octal byte structure directly to your screen for deep forensic analysis, you must use the od (Octal Dump) command.

How the od Command Works

The od command is a low-level diagnostic engine. It completely ignores standard file extensions and formatting rules. Instead, it reads the file exactly as the CPU reads it—byte by byte—and mathematically translates those invisible bytes into a strict, human-readable numerical matrix.

To execute a basic octal dump on a compiled binary named program.bin, simply type:

od program.bin

The terminal will instantly output a highly structured grid of octal (base-8) numbers. The far-left column represents the exact byte offset (the mathematical address of the data within the file), and the subsequent columns display the actual raw data chunks.

Dumping in Hexadecimal (Hex) Format

While the command is named “Octal Dump” for historical legacy reasons, modern computer science and reverse engineering rely almost exclusively on Hexadecimal (base-16) formatting. Reading base-8 octal is highly inefficient.

To force the engine to completely abandon its default octal output and render the raw bytes in perfect, two-character hexadecimal format (e.g., FF, 0A, C3), you must append the -x flag.

od -x program.bin

The terminal will instantly restructure the output into a pristine hex dump, allowing you to easily identify magic numbers, file headers, and hidden data structures buried deep inside the binary file.

Viewing the ASCII Translation

When reverse-engineering a binary file, you are often looking for hidden strings of human-readable text (like error messages, hardcoded passwords, or URLs) buried amongst the chaotic machine code.

To force the engine to output the raw hexadecimal bytes while simultaneously attempting to translate those bytes into standard ASCII characters on the exact same line, you must use the -c (character) flag.

od -c program.bin

The od engine will mathematically align the raw byte values directly above their corresponding ASCII letter translations, instantly exposing any hidden, human-readable text strings trapped inside the compiled binary architecture.

Get the best tech tips delivered straight to your inbox.

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