Jump to content

Md5sum: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Addbot (talk | contribs)
m Bot: Migrating 6 interwiki links, now provided by Wikidata on d:q1932013 (Report Errors)
Cravix (talk | contribs)
m adjust
Line 8: Line 8:


===Create MD5 hash file hash.md5===
===Create MD5 hash file hash.md5===
<source lang="bash">
<pre>
$ md5sum filetohashA.txt >> hash.md5
$ md5sum filetohashA.txt filetohashB.txt filetohashC.txt > hash.md5
</source>
$ md5sum filetohashB.txt >> hash.md5
$ md5sum filetohashC.txt >> hash.md5
</pre>
====File produced====
====File produced====
File contains filename and hash pairs.
File contains filename and hash pairs.
<source lang="bash">
<pre>
$ cat hash.md5
$ cat hash.md5
595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt
595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt
71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt
71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt
43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt
43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt
</pre>
</source>


Note: There must be two spaces between each md5sum value and filename to be compared. Otherwise, the following error will result: "no properly formatted MD5 checksum lines found".
Note: There must be two spaces between each md5sum value and filename to be compared. Otherwise, the following error will result: "no properly formatted MD5 checksum lines found".
Line 27: Line 25:


===Check MD5===
===Check MD5===
<source lang="bash">
<pre>
$ md5sum -c hash.md5
$ md5sum -c hash.md5
filetohashA.txt: OK
filetohashA.txt: OK
filetohashB.txt: OK
filetohashB.txt: OK
filetohashC.txt: OK
filetohashC.txt: OK
</pre>
</source>


===Check single MD5===
===Check single MD5===
<source lang="bash">
<pre>
$ echo "595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt" | md5sum -c
$ echo "595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt" | md5sum -c
filetohashA.txt: OK
filetohashA.txt: OK
</pre>
</source>


== See also ==
== See also ==
Line 50: Line 48:


== External links ==
== External links ==
* {{man|1|md5sum}}
* [http://www.linuxmanpages.com/man1/md5sum.1.php The program's manual page]
* [http://support.microsoft.com/kb/841290 Microsoft's File Checksum Integrity Verifier Utility ]
* [http://support.microsoft.com/kb/841290 Microsoft's File Checksum Integrity Verifier Utility ]



Revision as of 02:19, 14 March 2013

md5sum is a computer program that calculates and verifies 128-bit MD5 hashes, as described in RFC 1321. The MD5 hash (or checksum) functions as a compact digital fingerprint of a file. As with all such hashing algorithms, there is theoretically an unlimited number of files that will have any given MD5 hash. However, it is very unlikely that any two non-identical files in the real world will have the same MD5 hash, unless they have been specifically created to have the same hash. The underlying MD5 algorithm is no longer deemed secure, thus while md5sum is well-suited for identifying known files in situations that are not security related, it should not be relied on if there is a chance that files have been purposefully and maliciously tampered. In the latter case, the use of a newer hashing tool such as sha256sum is highly recommended.

Virtually any non-malicious change to a file will cause its MD5 hash to change; therefore md5sum is used to verify the integrity of files. Most commonly, md5sum is used to verify that a file has not changed as a result of a faulty file transfer, a disk error or non-malicious meddling. The md5sum program is installed by default in most Unix, Linux, and Unix-like operating systems or compatibility layers. Other operating systems, including Microsoft Windows and BSD variants — such as Mac OS X - have similar utilities (see external links). On FreeBSD this utility is called 'md5' and contains additional features.

Examples

All of the following files are assumed to be in the current directory.

Create MD5 hash file hash.md5

$ md5sum filetohashA.txt filetohashB.txt filetohashC.txt > hash.md5

File produced

File contains filename and hash pairs.

$ cat hash.md5
595f44fec1e92a71d3e9e77456ba80d1  filetohashA.txt
71f920fa275127a7b60fa4d4d41432a3  filetohashB.txt
43c191bf6d6c3f263a8cd0efd4a058ab  filetohashC.txt

Note: There must be two spaces between each md5sum value and filename to be compared. Otherwise, the following error will result: "no properly formatted MD5 checksum lines found".

Note: The file must be also UNIX line ending formatted otherwise you will see "md5sum: WARNING: x listed files could not be read". 'dos2unix' will convert it quickly if it is DOS/Windows formatted.

Check MD5

$ md5sum -c hash.md5
filetohashA.txt: OK
filetohashB.txt: OK
filetohashC.txt: OK

Check single MD5

$ echo "595f44fec1e92a71d3e9e77456ba80d1  filetohashA.txt" | md5sum -c
filetohashA.txt: OK

See also