md5sum Verifying file Integrity

Source: Internet
Author: User

1. Introduction
The MD5 algorithm is often used to verify the integrity of network file transfers and to prevent tampering with files.
MD5 Full name is the paper Digest to the algorithm (Message-digest algorithm 5), the algorithm for arbitrary length of information is calculated bitwise, resulting in a binary length of 128 bits (hex length is 32 bits) "fingerprint" (or "Digest to"), different files produce phase The likelihood of the same newspaper digest is very, very small.
On Linux or UNIX, md5sum is the tool used to calculate and verify the file digest. In general, after installing Linux, there will be md5sum this tool, directly run directly at the command line terminal.
2. Command Format
   md5sum [OPTION] ... [FILE] ...
3. Command Options
- bor--binary: Treat the input file as a binary file.
- Tor--text: treats the input file as a text file (default).
- Cor--check: Used to read MD5 information from a file to check the consistency of the file. (see info for details)
--status: This option is used with check, not output at check time, but the result of the check is represented by the return value.
- Wor--warn: When checking, check the input MD5 information and no illegal line, if any, output the corresponding information.
4. Example
(1) The MD5 value of a file is produced as follows:
[Email protected] www.linuxidc.com]# md5sum p182 > Cc.txt

In this way, to produce the file p182 MD5 check file cc.txt, open Cc.txt can see the following:
[email protected] www.linuxidc.com]# cat Cc.txt
dd05e55e3aca2d39e49a1a7d1b3fd404 p182

(2) Check whether two files are the same, you can compare the MD5 value of two files
[Email protected] www.linuxidc.com]# md5sum p182 > Ee.txt
[email protected] www.linuxidc.com]# cat Ee.txt
0f0b000b096ac947d6067466cc60ffd0 p182

[Email protected] www.linuxidc.com]# md5sum p183 > Ff.txt
[email protected] www.linuxidc.com]# cat Ff.txt
dd05e55e3aca2d39e49a1a7d1b3fd404 p183

(3) Judge whether a file is modified by MD5

[Email protected] www.linuxidc.com]# md5sum p182 > Cc.txt
[email protected] www.linuxidc.com]# cat Cc.txt
0f0b000b096ac947d6067466cc60ffd0 p182

Modify the following p182 file:
[Email protected] www.linuxidc.com]# VI p182
Compare with the original MD5 results:
[Email protected] www.linuxidc.com]# md5sum p182-c cc.txt
Md5sum:p182:no properly formatted MD5 checksum lines found
P182:failed
Md5sum:warning:1 of 1 computed checksum did not match

The result of the modification is as follows: MD5
[Email protected] www.linuxidc.com]# md5sum p182 > Dd.txt
[email protected] www.linuxidc.com]# cat Dd.txt
521e87e3331e94a483aec6bf19039845 p182

md5sum Verifying file Integrity

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.