Re: How do you use md5sum?

From: Barton L. Phillips (bartonphillips_at_sbcglobal.net)
Date: 04/30/05


Date: Sat, 30 Apr 2005 01:22:43 GMT

Unruh wrote:
> faeychild <phobos@deimos.com> writes:
>
>
>>Unruh wrote:
>
>
>>>Ohmster <notareal@emailaddress.com> writes:
>>>
>>>
>>>>How do I check that these are indeed "official" FC3 image files and are
>>>>the same as those offered by the linuxiso website? Running md5sum like
>>>>this:
>>>
>>>>[ohmster@ohmster FC3]$ md5sum FC3-i386-disc1.iso
>>>>db8c7254beeb4f6b891d1ed3f689b412 FC3-i386-disc1.iso
>>>>[ohmster@ohmster FC3]$
>>>
>>>>Gives me this huge number that I could check against the md5sum number
>>>>on the linuxiso website or ever on the alternate download site, but that
>>>
>>>Good. You have got it.
>>>Now why would that leave lots of room for human error. Any change in the
>>>files is likely to cause half of the bits in the md5sum to change. Ie,
>>>each character remaining the same has about a 1/16 chance. 5 given
>>
>>His point is - comparing the output of md5sum with the actual checksum
>>number, by eye, is error prone.
>
>
> No, it is not. IF the files are not the same, there are liable to be fewer than
> 3
> digits of 32 which agree. Seeing that at least one digits differs if 94% of the
> digits differ is not hard to do by eye. The probability that say even 10
> (out of 32) digits are the same is very very small.
> Ie, comparing by eye has a very very low probability of error.
>
>
>
>>There may be some way to pipe the output of md5sum through a compare
>>function, but I don't know it. Surely a script wouldn't be too difficult
>>to knock up.
>>Then again, compairing checksums is not something I do too frequently.
>
>
> man md5sum
>
The --check option was new to me. I had never read the man on md5sum
that carefully. As it is the 'info coreutils md5sum' was more helpful
though still pretty hard to understand. An example would have helped so
here is one or two:

md5sum abc | md5sum --check

a=`md5sum abc`
echo "$a" | md5sum --check

In both cases what happens is that the output from md5sum is used as the
input. The output has the md5sum and the 'type' and the filename. Most
of the time the 'type' is ' ' (a space unless the file is forced to
binary by --binary in which case the 'type' is '*'). When md5sum is
invoked with --check it uses the filename which was part of the previous
md5sum as the filename to compare.

I actually think the man/info could have been clearer as it took me
several tries to get it to work. But then again one man's obtuse is
another 'clear as a bell'.

Anyway in the case of a download from the web you would need to cut and
past the md5 from the webpage (or download the md5 file) and then feed
that to the md5sum --check. Actually I think my little perl script might
be easier.



Relevant Pages