Most developers know diff. Fewer know its quieter sibling: cmp — and that gap shows up the moment you need to compare something diff wasn't built for.
diff is a text-diffing tool. Feed it a compiled binary, a disk image, or a compressed archive, and you either get garbage output or a flat "binary files differ" with zero useful detail. cmp doesn't have that problem — it treats every file as a raw byte stream and tells you the exact byte (and line, for text) where two files first diverge. That makes it the right tool for validating builds, checking backups, verifying downloads, and catching unexpected changes in config files or executables.
I wrote up a full breakdown of cmp aimed at engineers and SOC-adjacent devs who want a fast, dependency-free integrity check without reaching for a full monitoring stack:
- cmp vs diff — the actual technical distinction and when each applies
- A real-world scenario: catching a tampered config file with a single command
- Every practical flag explained (-s for scripting, -n for byte-range limits, -i for offset skipping) with concrete use cases
- How to wire cmp -s into shell scripts, cron jobs, and CI pipelines using exit-status logic
- Where cmp fits (and where it doesn't) next to enterprise file integrity monitoring and compliance frameworks like PCI DSS and HIPAA
If you've ever needed to confirm two binaries, ISOs, or config files are byte-for-byte identical without pulling in extra tooling, this one's worth a read.
Full guide: https://www.xpert4cyber.com/2026/09/linux-cmp-command-guide.html
Top comments (0)