hd
Display file contents in hexadecimal format
TLDR
View documentation for the original command
SYNOPSIS
hd [OPTIONS] [FILE...]
Note: The hd command is commonly an alias for hexdump -C. Therefore, its options are typically those supported by hexdump when used with the canonical output format.
PARAMETERS
FILE...
One or more input files to be dumped. If no FILE is specified, hd reads from standard input.
-n count
Interpret only count bytes of input.
-s offset
Skip offset bytes from the beginning of the input before dumping.
-v
Display all input data. By default, hd (via hexdump) replaces lines of identical input with an asterisk ('*') to conserve space. The -v option forces all data to be displayed.
DESCRIPTION
hd is a utility used to display the contents of files or standard input in a canonical hexadecimal and ASCII format. It is most commonly implemented as a symbolic link or an alias to the hexdump -C command, which is part of the util-linux package. This command is invaluable for inspecting binary data, debugging compiled programs, analyzing network packet captures, or examining disk images.
The output of hd presents data in three main columns: an offset from the beginning of the input, the hexadecimal representation of the bytes (typically 16 bytes per line), and the corresponding ASCII characters for those bytes. Non-printable ASCII characters are usually represented by a dot ('.'). hd provides a quick and clear way to visualize the raw byte structure of any file, making it an essential tool for developers, security analysts, and system administrators working with low-level data.
CAVEATS
hd is generally a convenience alias for hexdump -C and not a standalone utility with its own independent development or complex options. Its availability and exact behavior can depend on the system's util-linux version or shell configurations. For very large files, the output can be extensive. Always use with caution, especially when piping to other commands.
<I>OUTPUT FORMAT EXPLAINED</I>
The output of hd typically consists of three parts per line:
1. Offset: The byte offset from the beginning of the input, usually in hexadecimal.
2. Hexadecimal Bytes: 16 bytes of input data displayed in hexadecimal pairs, often grouped into two blocks of 8 bytes.
3. ASCII Representation: The ASCII characters corresponding to the 16 bytes. Non-printable characters are represented by a dot ('.').
<I>COMMON USE CASES</I>
hd is highly useful for:
- Debugging: Understanding the raw structure of binary files, executables, or core dumps.
- Forensics: Inspecting disk images, memory dumps, or network packet captures for specific byte sequences or artifacts.
- Reverse Engineering: Analyzing compiled programs to understand their internal data structures or code sections.
- File Header Inspection: Quickly viewing the initial bytes of a file to identify its format based on magic numbers.
HISTORY
The functionality provided by hd (canonical hex dumping) originates from the hexdump utility, which has been a part of Unix-like systems for decades. hexdump itself is maintained as part of the util-linux project, a collection of essential Linux system utilities. The specific hd command is a common and convenient alias or symbolic link to hexdump -C, allowing users to quickly access this canonical output format without typing the full option.