How to generate and verify an MD5 hash on Linux

An MD5 hash is commonly used to compare and verify the integrity of a file. To create the MD5 hash we can use the tool MD5SUM which is included in Linux and Unix like operating systems. MD5SUM can calculate, generate, and verify MD5 hashes.

Remember if the file becomes damaged or corrupted the hash will no longer match.

Generate the hash

We want to generate an MD5 hash for the file.iso and save the result to a text file named file.iso.md5.

md5sum file.iso > file.iso.md5

Verify hash

Because we have the hash in a text file we can place the hash file and target file in the same folder then issue the following command, if the hash matches the output will be OK.

md5sum -c file.iso.md5

Or if you want to view the string of characters and do a visual comparison then use.

md5sum file.iso

And compare it with the hash file you already have.

Despite suffering from weaknesses MD5 still remains the best option when it comes to integrity verification.

  • Saverio

    There is also another simple application “Checksums calculator” a GUI tool to calculate md5 witch can run under Linux, Windows and MacOS x operating systems on both 32 and 64bit architectures. For more info take a look here: