HOWTO: Install md5sum & sha1sum on Mac OS X

I was a bit surprised to learn that my Mac didn't have the md5sum and sha1sum tools installed by default. A quick search and I found a site that provides the source. The sources compiled successfully on my Mac (OS X 10.5.5, xCode tools installed).

The only quirk appears in the last step:

$ ./configure
$ make
$ sudo make install
cp md5sum sha1sum ripemd160sum /usr/local/bin
chown bin:bin /usr/local/bin/md5sum /usr/local/bin/sha1sum
chown: bin: Invalid argument
make: *** [install] Error 1

The make install command tries to change the ownership of the files to the bin user. Since that user doesn't exist on my system, the command fails. This isn't a problem though, as both binaries work perfectly. By default, they are installed to /usr/local/bin/.

Using the OS X md5 instead of md5sum

As a commenter pointed out, the /sbin/md5 utility provided by OS X contains a hidden -r switch that causes it to output in a format identical to that of md5sum, making it compatible with scripts that require md5sum's format. If you want to use the md5 utility provided by OS X, you can add the following to your ~/.profile or ~/.bashrc:

alias md5='md5 -r'
alias md5sum='md5 -r'

Installing with HomeBrew

A commenter mentioned that you can install md5sum using HomeBrew by running brew install coreutils.

Update (2015-02-25): The current method for installing via HomeBrew is as follows:

brew install md5sha1sum

Installing with MacPorts

A commenter mentioned if you have MacPorts installed, you can run port install coreutils but "you’ll need to add /opt/local/libexec/gnubin/ to your PATH.

Update (2014-08-25): It appears that you should use sudo port install md5sha1sum.

Write a Comment



  1. seems they only include md5, which may have a slightly different output to md5sum, but from what I gather, does the same thing..? still, they could have made md5sum symlink to md5

  2. Hey Nevyn,

    You’re absolutely correct! OS X includes /sbin/md5, however it’s output is different than the md5sum utility:

    $ md5 myfile.iso
    MD5 (myfile.iso) = 3d763a372e34681287712f661ecb598c

    $ md5sum myfile.iso
    3d763a372e34681287712f661ecb598c myfile.iso

    Many scripts that utilize the md5sum utility expect the output to be in a particular format. If the format is different (as it is with the md5 command), it will break the scripts that use it.

  3. I haven't found an md5sum that wasn't exactly as calculated using md5 on the Mac. (OSX 10.4.11).
    For sha1sum you can do "openssl sha1 <path/filename.ext>".

  4. Won’t quite do the same since it won’t actually accept a source file to check sha1 sums against, but if you just need to generate compatible output, you could try defining the following function in your .bashrc:

    sha1sum ()
    openssl sha1 $1 | sed ‘s/.*((.*))= (.*)$/2 1/’

    This will, on a “sha1sum foo.txt” generate the expected output…

  5. Thank you for the comment about -r option, was really usefull for me as I’m moving my video files from my iMac to a file server running Debian GNU/Linux and using md5sum to verify data integrity after copy.

    Actually I’ve got an addon:
    the -r hidden option does not really respect the format, indeed if you do something like:

    ssh user@imac “cd /Volumes/To/Copy; find . -type f -print0 | xargs -0 md5 -r” | md5sum -c

    using the check option (-c) on linux side, then it will complain that the md5 output format is not valid. Indeed. MacOSX md5 -r generates lines with “” separated with *one* space with the “”. However, the Linux version of md5sum requires 2.

    So you can add “| sed s’/ / /’ |” and it will work like a charm 🙂

    Thank you again for this information.

  6. Does not appear to work at all in Maverick.

    —–Using your method just bombs:
    $ ./configure
    setting prefix… /usr/local
    checking system type… Interestink. OS X
    checking for a C compiler… /usr/bin/gcc
    checking to see if /usr/local/bin/md5sum is Microbrew… does not exist
    checking to see if /usr/local/bin/sha1sum is Microbrew… does not exist
    checking to see if /usr/local/bin/ripemd160sum is Microbrew… does not exist
    looking for OpenSSL headers ‘openssl/md5.h’… Cannot find it.
    Please run this script as such: SSLINCPATH= ./configure
    $ make
    Makefile:27: No such file or directory
    Please run ‘configure’ first.

    make: /bin/false: No such file or directory
    make: *** [] Error 1

    ——Using mac ports returns nothing:

    $ sudo port install md5sum
    Warning: port definitions are more than two weeks old, consider using selfupdate
    Error: Port md5sum not found
    To report a bug, see

    $ sudo port install sha1sum
    Warning: port definitions are more than two weeks old, consider using selfupdate
    Error: Port sha1sum not found
    To report a bug, see

    $ which md5sum
    $ which sha1sum


  • Einrichtung des Archivcomputers | k & r December 6, 2020
  • Jason Kajita December 6, 2020
  • Rffuste December 6, 2020
  • Evo 4G update to Froyo OFFICIAL August 3rd - Page 68 - Android Central Forums December 6, 2020
  • Lance Quejada December 6, 2020
  • Roberto Nogueira December 6, 2020
  • md5sum recursive from ./ « December 6, 2020