Verify file accuracy with md5sum

Source: Internet
Author: User
Use md5sum to verify the file accuracy-general Linux technology-Linux technology and application information. The following is a detailed description. In general, we first install linux images from the Internet, and then install or burn the hard disk to a CD before using it.

Before using these downloaded files, we must check the correctness. Otherwise, it may be a waste of time or CD.

When the download site provides the content itself, it also provides a file named MD5SUM or similar name.

In fact, this file is used for verification.

The following describes the entire process of using md5sum through a comprehensive small instance.

Requirement: upload files under/var/www to another machine through a network or a mobile hard disk.

Steps:

Cd/var/www
Md5sum *> MD5SUM

If/var/www contains folders, an error message is displayed, as shown in the following figure:

Md5sum: ajax: Is a directory
Md5sum: apache2-default: Is a directory
Md5sum: blog: Is a directory
Md5sum: codeblocks: Is a directory
Md5sum: download: Is a directory
Md5sum: php100: Is a directory

Let's check what is generated:
Cat MD5SUM

Here is:
40491cfa725e9f612597e18e5cb5a731 cube-bot-0.32.tar.gz
71b29ffeaa1_caecaeb6f30813814f5 hack2.js
D779f6b43832a6d65621340fbeb0c398 hack2.js ~
9dccf462d245f55ac3e0cdb0e5401f5b index2.php
4afbe1cc2bd8eb97a4e6c51e6aaf5202 ipgw. py
Af7788191a44f32a9d4aafa3aa7f61c4 md5sum
9dccf462d245f55ac3e0cdb0e5401f5b phpinfo. php
2883fddfd2a1c9a448ab0%2beeda81 r. php
60880cf2774e5f54159f0e7555a6c723 r. php ~
6bb2425f1cd9922c46e15c2253a99c27 s.html
D3e265f801b2f3b7fa37b5578ad83ffb s.html ~
9175a6e91a1a909eae8baf532c44eccf ss.html
A6cc3964fb87d1b3ed3829b0c2d1b4c6 ss.html ~
Aee6dc4a6715f93747137c19d151c51c w21 ~
4e313605a6602d7c516ec6bb32a43bad w21.html
4e313605a6602d7c516ec6bb32a43bad w21.html ~
20a76cde1afb88df632c5a13d0bff1c5 w2.html
A7f67a7d9b59e2c2dae6f917e9b59934 w2.html ~

Now we can move it to another location by various means. Assuming that the file has been moved, we need to verify whether the file is damaged during the moving process. Assume that the folder content is moved to/tmp/test:

Cd/tmp/test
Md5sum-c MD5SUM

The output in this example is:
Hack2.js: OK
Hack2.js ~ : OK
Index2.php: OK
Ipgw. py: OK
Md5sum: OK
Phpinfo. php: OK
R. php: OK
R. php ~ : OK
S.html: OK
S.html ~ : OK
Ss.html: OK
Ss.html ~ : OK
W21 ~ : OK
W21.html: OK
W21.html ~ : OK
W2.html: OK
W2.html ~ : OK

If all the output results are OK, the content is not changed.

Here, we can simulate a transmission error.

Make any modification in the r. php file. Here, a space is added at the beginning. The result is as follows:

Cube-bot-0.32.tar.gz: OK
Hack2.js: OK
Hack2.js ~ : OK
Index2.php: OK
Ipgw. py: OK
Md5sum: OK
Phpinfo. php: OK
R. php: FAILED
R. php ~ : FAILED
S.html: OK
S.html ~ : OK
Ss.html: OK
Ss.html ~ : OK
W21 ~ : OK
W21.html: OK
W21.html ~ : OK
W2.html: OK
W2.html ~ : OK
Md5sum: WARNING: 2 of 18 computed checksums did NOT match

The modification involved two files, so the verification of both files failed.

What if I delete an object? In this case, w2.html ~ Deleted. Check the result:

Cube-bot-0.32.tar.gz: OK
Hack2.js: OK
Hack2.js ~ : OK
Index2.php: OK
Ipgw. py: OK
Md5sum: OK
Phpinfo. php: OK
R. php: FAILED
R. php ~ : FAILED
S.html: OK
S.html ~ : OK
Ss.html: OK
Ss.html ~ : OK
W21 ~ : OK
W21.html: OK
W21.html ~ : OK
W2.html: OK
Md5sum: w2.html ~ : No such file or directory
W2.html ~ : FAILED open or read
Md5sum: WARNING: 1 of 18 listed files cocould not be read
Md5sum: WARNING: 2 of 17 computed checksums did NOT match

It may take a long time to upload large files!

For example, it took me almost ten minutes to verify the SUSE-Linux-10.1-GM-DVD-i386.iso I just placed. However, considering data integrity and correctness, it is worth investing.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.