Skip to content
Home » Does macOS Have md5sum? Yes, and It Matches GNU

Does macOS Have md5sum? Yes, and It Matches GNU

Dark terminal card headed md5sum is already on your Mac, showing command -v md5sum returning /sbin/md5sum, then md5sum sample.txt printing the hash followed by the filename labelled GNU, and md5 sample.txt printing MD5 (sample.txt) equals the same hash labelled BSD

Carry a checksum habit over from Linux and the standard advice for a Mac is blunt: macOS has no md5sum, so use md5 instead. On macOS 26.5.2 that advice is out of date. Run command -v md5sum and it answers /sbin/md5sum. The whole family is there, sha1sum through sha512sum, and the output already lines up with the GNU tools those names come from — check mode included. This page shows what actually ships, how it behaves, and where md5 and shasum still fit.

md5sum on macOS

Nothing needs installing. On macOS 26.5.2 every GNU-style digest name resolves inside /sbin:

$ command -v md5sum sha1sum sha256sum sha512sum
/sbin/md5sum
/sbin/sha1sum
/sbin/sha256sum
/sbin/sha512sum

There is no /usr/bin/md5sum. The commands live in /sbin, which is already on the default PATH, so md5sum on a Mac runs without a full path. All of them are hardlinks into the same compact BSD tool, which decides how to behave from the name you invoke it by. Apple describes the arrangement in one man page whose NAME line lists every alias:

md5, sha1, sha224, sha256, sha384, sha512, md5sum, sha1sum, sha224sum,
sha256sum, sha384sum, sha512sum – calculate a message-digest fingerprint
(checksum) for a file

So the “macOS has no md5sum” line describes an older Mac, not a current one. If you are on a system where the command really is missing, the last section covers it. Everywhere else, the tool is sitting in /sbin waiting to be called.

Output format and GNU compatibility

The reason the alias matters is the format. Called by its BSD name, md5 prints the hash last. Called as md5sum, the same binary prints the GNU layout — hash first, two spaces, then the filename:

$ md5sum sample.txt
b1946ac92492d2347c6235b4d2611184  sample.txt
$ md5 sample.txt
MD5 (sample.txt) = b1946ac92492d2347c6235b4d2611184

That two-space separator is not cosmetic. Scripts and CI steps written for Linux parse exactly that shape, and sha256sum produces it too. A filename of - marks input read from a pipe, matching how the GNU tools report standard input:

$ sha256sum sample.txt
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03  sample.txt
$ echo hi | sha256sum
98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4  -

The man page states the intent in plain words. The sum-named tools, it says, “do the same, but with command-line options and an output format that match those of their similarly named GNU utilities.” That is the whole point of the aliases, and it is why a Linux script often needs no edits at all.

Check mode (-c)

The feature people assume is absent is check mode, where you hand the tool a file of digests and it re-hashes each entry. It works. Save a digest, then verify against it:

$ md5sum sample.txt > sums.md5
$ md5sum -c sums.md5
sample.txt: OK

A file that has changed reports FAILED instead of OK and sets a non-zero exit status, which is what a build step actually tests. This is the GNU meaning of -c. It is worth flagging because the BSD tool reads the same flag differently: md5 -c string compares one file against a single digest you type on the command line. One letter, two behaviours, decided entirely by which name you called.

Verifying a download

The everyday reason to reach for any of these on a Mac is a download that publishes a checksum. The pattern is the check mode from above, pointed at a real file. Hash what you fetched with the algorithm the page used, usually SHA-256, and read the result:

$ sha256sum sample.txt
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03  sample.txt

Reading two 64-character strings by eye is where mistakes creep in, so let the tool compare them instead. Drop the published hash and the filename into a check file, then run the verifier. A match prints OK; a changed file prints a warning and FAILED, and sets a non-zero exit status a script can act on:

$ echo "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03  sample.txt" > SHA256SUMS
$ sha256sum -c SHA256SUMS
sample.txt: OK

$ sha256sum -c SHA256SUMS      # after the file was edited
sha256sum: WARNING: 1 computed checksum did NOT match
sample.txt: FAILED

One caveat is worth stating plainly. A checksum only proves the bytes match the number the publisher listed. Anyone who can alter the file can usually alter the hash printed beside it, so a value taken from the same page as a tampered download proves little by itself. What it catches every time is a corrupted or truncated transfer, and that is the job it is genuinely good at.

md5 vs md5sum vs shasum

Three tools cover the same ground on a Mac. Knowing which is which saves a confusing afternoon:

  • md5 / sha256 — the BSD names, printing MD5 (file) = hash. Add -q for the bare hash, or -r to reverse it to hash-then-filename.
  • md5sum / sha256sum — the GNU names, with the layout and -c mode above.
  • shasum — a Perl script at /usr/bin/shasum with a selectable algorithm. shasum -a 256 matches sha256sum, and it carries its own -c check mode.

The reversed form and the algorithm switch are easy to see side by side:

$ md5 -r sample.txt
b1946ac92492d2347c6235b4d2611184 sample.txt
$ shasum -a 256 sample.txt
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03  sample.txt

For a one-off comparison against a hash printed on a download page, any of the three does the job. For a script moved over from a Linux box, the sum-named commands are the ones that need no changes.

Fallbacks for older Macs

If command -v md5sum comes back empty on an older system, two paths get you there. The BSD md5 is always present, so md5 -r file gives a hash-then-name line that most tools accept. Or install GNU coreutils, which ships the real binaries under a g prefix so they never shadow a system command:

brew install coreutils
# then: gmd5sum, gsha256sum, gsha512sum, ...

The prefixed names are the genuine GNU tools, the same ones a Linux distribution ships. On macOS 26.5.2 you need none of that, because the built-in md5sum already behaves like them.

Quick reference

CommandPrintsNotes
md5sum filehash fileGNU layout, built in at /sbin
md5 fileMD5 (file) = hashBSD default
md5 -r filehash filereversed, single space
sha256sum filehash fileGNU layout
shasum -a 256 filehash filePerl tool, pick the algorithm
md5sum -c sums.md5file: OK / FAILEDverify a saved list of digests

The short version for a Mac on 26.5.2: md5sum and its sha*sum siblings are already installed, already GNU-formatted, and already handle -c. Reach for md5 or shasum when you want the BSD layout or a chosen algorithm — not because the GNU-named command is missing, because it is not.

Leave a Reply

Your email address will not be published. Required fields are marked *