Skip to content

Linux od command

The ‘od’ command in Linux is a versatile tool for analyzing file contents in different formats. It can display data in octal, decimal, hexadecimal, and ASCII, making it ideal for examining binary files. With various options to customize the output, such as byte order and data representation, ‘od’ is commonly used for debugging and data analysis tasks.

Terminal window
od [options] [file]
OptionDescription
-ASpecify the output format
-tSpecify the data type format
-jSkip a specified number of bytes
-NLimit the number of bytes to output
-vDisplay all input data
-wSpecify the number of bytes per line
-xDisplay output in hexadecimal format
-cDisplay output as ASCII characters
ParameterDescription
fileThe input file to display in octal
Terminal window
od /path/to/file.txt

This command displays the contents of the file in octal format.

Terminal window
od -x /path/to/file.txt

Using the -x option with the od command, the file contents are displayed in hexadecimal format.

Terminal window
od -N 20 /path/to/file.txt

By specifying the -N option followed by a number, you can display a specific number of bytes from the file.

Output Characters with Non-Graphic Formats as Octal

Section titled “Output Characters with Non-Graphic Formats as Octal”
Terminal window
od -c /path/to/file.txt

With the -c option, the command displays characters with non-graphic formats in octal.

To use the od command in Linux, execute the following command:

Terminal window
od file.txt

What are common options used with od in Linux?

Section titled “What are common options used with od in Linux?”

Common options used with the od command in Linux include:

Terminal window
od -t x1 file.txt

How can I display a specific number of bytes per line with od in Linux?

Section titled “How can I display a specific number of bytes per line with od in Linux?”

To display a specific number of bytes per line with the od command in Linux, use the following command:

Terminal window
od -N4 file.txt

How can I skip a certain number of bytes before starting to dump with od in Linux?

Section titled “How can I skip a certain number of bytes before starting to dump with od in Linux?”

To skip a certain number of bytes before starting to dump with the od command in Linux, use the following command:

Terminal window
od -j2 file.txt

How do I interpret binary data using od in Linux?

Section titled “How do I interpret binary data using od in Linux?”

To interpret binary data using the od command in Linux, use the following command:

Terminal window
od -b file.txt

How can I display the hexadecimal offset within each line using od in Linux?

Section titled “How can I display the hexadecimal offset within each line using od in Linux?”

To display the hexadecimal offset within each line using the od command in Linux, use the following command:

Terminal window
od -A x file.txt

How can I change the output format to decimal using od in Linux?

Section titled “How can I change the output format to decimal using od in Linux?”

To change the output format to decimal using the od command in Linux, use the following command:

Terminal window
od -t d2 file.txt
  1. Displaying the content of binary files
  2. Viewing non-text files in a human-readable format
  3. Extracting data from binary files
  4. Checking file encoding
  5. Debugging files and data structures
  6. Converting data between different formats
  7. Inspecting memory dumps
  8. Analyzing file formats