UNIX / Linux md5sum Command Examples

by SathiyaMoorthy

What is md5sum?
5 md5sum examples
Syntax and Options
Related Commands

What is md5sum?

md5sum is a 128 bit checksum which will be unique for the same data provided. Use md5sum command to calculate and cross check the md5sum.

Two non identical files will never have the same md5sum. Typically, md5sum is used to cross verify the integrity of a file after downloading it from a website.

5 md5sum Examples

Calculate / Compute md5sum

Calculate or compute md5sum for the input file.

$ md5sum samplefile.txt
3b85ec9ab2984b91070128be6aae25eb  samplefile.txt

Calculate or compute md5sum for the input given through STDIN.

$ md5sum -
d8e8fca2dc0f896fd7cb4cb0031ba249  -

Compute and Verify checksum of files

Compute and store the md5sum of files in a file, and then cross check it with -c option.

$ md5sum *.vim
bbd166fee3f3f624286c4d85dc1994f8  NERD_tree.vim
50dcf8c353827eef464cb79f55018d6c  SearchComplete.vim
5d2a1217ddecff630528c64a04ee7f9e  utl.vim

$ md5sum *.vim > t.md5

$ md5sum -c t.md5 
NERD_tree.vim: OK
SearchComplete.vim: OK
utl.vim: OK

When there is a change in any of the file, you will get the “computed checksums did NOT match” warning message.

$ md5sum -c t.md5 
NERD_tree.vim: OK
SearchComplete.vim: OK
utl.vim: FAILED
md5sum: WARNING: 1 of 3 computed checksums did NOT match

Syntax and Options

md5sum [OPTION]… [FILE]…

Short Option Long Option Option Description
-b –binary read in binary mode
-c –check read MD5 sums from the FILEs and check them
-t –text read in text mode (default)
–quiet don’t print OK for each successfully verified file
–status don’t output anything, status code shows success
-w –warn warn about improperly formatted checksum lines

Related Commands


Leave a Comment

Previous post:

Next post: