• Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'md5sum' Command In Linux

2023-05-11 - By Robert Elder

     I use the 'md5sum' command to calculate the md5 checksum of files:

md5sum some-file.txt

     and the output will look something like this:

ed076287532e86365e841e92bfc50d8c  some-file.txt

     You can run the 'md5sum' command with one or more arguments to calculate the checksum of all of the files at once:

md5sum some-file.txt other-file.txt cat.mp4

     and the output will look something like this:

ed076287532e86365e841e92bfc50d8c  some-file.txt
e83e2f16a9b7646803c105099234ad17  other-file.txt
d077f244def8a70e5ea758bd8352fcd8  cat.mp4

Verifying MD5 Checksums In A File With 'md5sum'

     You can use the '-c' flag with the 'md5sum' command to specify a file that contains a list of file names and checksums.  Here, I have a file called 'checksums.txt' that contains the following list of checksums.  The format of these checksums is the same as the regular output from the 'md5sum' command:

d077f244def8a70e5ea758bd8352fcd8  cat.mp4
e83e2f16a9b7646803c105099234ad17  other-file.txt
ed076287532e86365e841e92bfc50d8c  some-file.txt

     If I run the 'md5sum' command like this:

md5sum -c checksums.txt

     the output will look something like this:

cat.mp4: OK
other-file.txt: OK
some-file.txt: OK

     Each file name listed in the checksum file will be compared against its expected checksum.  If the checksum fails to match, a message stating so will be displayed.  To test this, we can add some extra data to one of the files so that it's checksum doesn't match:

echo 'foo' >> cat.mp4

     And now, running the same command again:

md5sum -c checksums.txt

     produces the following output:

cat.mp4: FAILED
other-file.txt: OK
some-file.txt: OK
md5sum: WARNING: 1 computed checksum did NOT match

     The md5 checksum algorithm was historically considered to be cryptographically secure, however this is no longer the case as major security flaws in the algorithm have been found.  The md5 hash function is still useful for non-cryptographic purposes.

     And that's why the 'md5sum' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Published 2023-10-04
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List

Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
Privacy Policy      Store Policies      Terms of Use