How to compute the MD5 hash of a file

By | January 30, 2014

md5MD5 is one of the most common types of hash used to verify the integrity of a file after a transfer (and not only).

You may even find some files with .md5sum extension which contain the MD5 checksum of some existing files.

The MD5 hash is commonly expressed as a 32 digit hexadecimal number, e.g.: 1bc29b36f623ba82aaf6724fd3b16718

A simple way to generate this, is to use the md5sum command:

[[email protected] ~]# md5sum httpd-2.2.15-29.el6.centos.x86_64.rpm
f7de6883d5c12e7565955fbccb1b64ef  httpd-2.2.15-29.el6.centos.x86_64.rpm

You can also generate .md5sum files yourself with the same command by just redirecting the output into a file:

md5sum httpd-2.2.15-29.el6.centos.x86_64.rpm > httpd-2.2.15-29.el6.centos.x86_64.rpm.md5sum

Example:

-rw-rw-r--  1 root root 822K Aug 13 13:32 httpd-2.2.15-29.el6.centos.x86_64.rpm
-rw-rw-r--  1 root root   72 Jan 30 00:44 httpd-2.2.15-29.el6.centos.x86_64.rpm.md5sum

Of course, you can also use the checksum file to verify the integrity:

[[email protected] ~]# md5sum -c *.md5sum
httpd-2.2.15-29.el6.centos.x86_64.rpm: OK

Leave a Reply

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

Time limit is exhausted. Please reload the CAPTCHA.