md5 digests via md5sum

MD5 is a message digest algorithm that can hash a string or file. The md5sum is used on Linux systems to create MD5 digests.

Strings (terminal command line)

To create the md5 of a string via the command line:

echo -n "Digest this" | md5sum

The -n flag prevents echo adding a newline at the end of the string.

E.g:

whoever@wherever ~ $ echo -n "Digest this" | md5sum
8dbd68ca892adb12da89c4503471410d  -

Files

Generate an md5 checksum of [filename]:

md5sum [filename]

You can compare the output to the md5 checksum you downloaded with [filename] or you can use the -c flag to have md5sum do the comparison for you:

md5sum -c [checksum_filename]

E.g:

whoever@wherever ~ $ md5sum -c portage-latest.tar.bz2.md5sum 
portage-latest.tar.bz2: OK

If you have a digests file, this will contain the checksums for a number of files. E.g. Here’s one from the gentoo livedvd-amd64-multilib-10.1.iso.DIGESTS file:

# MD5 HASH
fc94c887efea405b7aff6b62ab10e12a  livedvd-amd64-multilib-10.1.iso
dc311f02c98ce99f4aa860c8e30f5910  livedvd-amd64-multilib-10.1.iso.CONTENTS
f4fa931a5637a55d58d76db788dbf46e  livedvd-amd64-multilib-10.1.iso.CONTENTS-squashfs.gz
# SHA1 HASH
e6d0ddd45a0ae280deae6de43c548cc31496a9a0  livedvd-amd64-multilib-10.1.iso
255c08c0595d3498061434278166e20320f0b0a3  livedvd-amd64-multilib-10.1.iso.CONTENTS
49bea82820ec53aa5da0aa2f797371dce1c4738d  livedvd-amd64-multilib-10.1.iso.CONTENTS-squashfs.gz

To automatically check all files listed in this digest, use the md5sum -c flag:

md5sum -c [digests_filename]

E.g:

whoever@wherever ~ $ md5sum -c livedvd-amd64-multilib-10.1.iso.DIGESTS
livedvd-amd64-multilib-10.1.iso: OK
livedvd-amd64-multilib-10.1.iso.CONTENTS: OK
livedvd-amd64-multilib-10.1.iso.CONTENTS-squashfs.gz: OK

If any of the files listed in the digest are missing you’ll get a warning message.

Last modified: 27/05/2014 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top