Name
md5sum — stdin stdout - file -- opt --help --version
Synopsis
md5sumfiles
| --checkfile
The md5sum
command works
with checksums to verify that files are unchanged. The first form
produces the 32-byte checksum of the given files, using the MD5
algorithm:
$ md5sum myfile dd63602df1cceb57966d085524c3980f myfile
while the second form tests whether a checksum matches its
file, using --check
:
$ md5sum file1 file2 file3 > mysum $ cat mysum 90a022707ca5b5fc8f465e7cbb954987 file1 86d19ef79d33c28cf0c9ba882f25cdb8 file2 d0dc53c9941e33a10e7f38ecc0de772f file3 $ md5sum --check mysum file1: OK file2: OK file3: OK $ echo "new data" > file2 $ md5sum --check mysum file1: OK file2: FAILED file3: OK md5sum: WARNING: 1 of 3 computed checksums did NOT match
Two different files are highly unlikely to have the same MD5 checksum, so comparing checksums is a reasonably reliable way to detect if two files differ:
$ md5sum myfile1 | cut -c1-32 > sum1 $ md5sum myfile2 | cut -c1-32 > sum2 $ diff -q sum1 sum2 Files sum1 and sum2 differ
Some other programs similar to md5sum
are sum
and cksum
, which use different algorithms to
compute their checksums. sum
is
compatible with other Unix systems, specifically BSD Unix (the
default) or System V Unix (-s
option), and cksum
produces a CRC
checksum:
$ sum myfile 12410 3 $ sum -s myfile 47909 6 myfile $ cksum myfile 1204834076 2863 myfile
The first integer is a checksum and the second is a block count. But as you can see, these checksums are small numbers and therefore ...
Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.