Because Linux system installation software is more complicated, if the downloaded software has been modified, it will be very troublesome to install. It is very important to check the integrity of the downloaded files in the Linux system. This article mainly introduces the shell script to achieve the integrity of the Linux system files. For sex detection, the script given in this article uses the MD5 comparison method to detect whether Linux system files have been replaced and other issues. Friends in need can refer to it.
There are currently three verification methods: MD5, SHA1, and PGP. In the long years of Windows (the vicissitudes of life have not happened), you can generally only come into contact with the first two - provided you can verify them.
MD5 check
Principle: Perform MD5 Hash on the file to find the MD5 hash value of the file. By whether the MD5 hash value of the file after downloading is consistent with the MD5 hash value provided by the publisher, it can be determined whether the file has been tampered with after the publisher published it.
Description: A long-lived Hash algorithm, it has a wide range of applications and is often used by websites to store passwords. The MD5 hash values generated by different files are unique, but there are already ways to make the MD5 hash values of the files consistent by making a small amount of modifications to the files.
Usage: Under CentOS, it is very simple to perform MD5 Hash on files. Just use the md5sum command:
The code is as follows:
# $ is the terminal prompt, not input.
## is a comment
# The output without prompt is the output
#Directly output MD5 Hash
$ md5sum your-downloaded-file-name
fd4a1b802373c57c10c926eb7ac823d8 your-downloaded-file-name《/p》《p》#Save the MD5 Hash value to the md5-hash.txt file.
$ md5sum your-downloaded-file-name 》 md5-hash.txt
# Display the output md5-hast.txt content
$ cat md5-hash.txt
fd4a1b802373c57c10c926eb7ac823d8 your-downloaded-file-name《/p》《p》# Use md5-hash.txt to verify whether the file you downloaded is correct.
$ md5sum -c md5-hash.txt
your-downloaded-file-name: OK
If you are the publisher of the file, you can send the hash value of the file to the verifier through md5sum, so that people who download your file can verify the correctness of your file through the MD5 hash value. Conversely, after we download the file on the website, we can also obtain the publisher's MD5 hash value and compare it with the locally generated Hash value. If they are consistent, the file is considered correct.
The above is the method summarized by the editor to detect the integrity of downloaded files. I hope it can help everyone. Learn more at Huajun Software Park!