How to verify SHA1 and MD5 in Linux system?

  

The files we download on the network or copied in the U disk are the same as the source files, but sometimes in case of download or copy error, we will It is found to be different from the source file, which is mainly reflected in the different hash values ​​of SHA1 and MD5. Both SHA1 and MD5 are important indicators for uniquely determining a file. Only SHA1 or MD5 values ​​are consistent to ensure that the downloaded file is correct. So, how do you verify SHA1 and MD5 on a Linux system? In fact, under

linux mostly built md5sum and sha1sum, maybe commands are twins, command format is basically exactly the same, we sha1sum example to explain:

most Simple usage: sha1sum [file path], which displays the SHA1 value of the specified file, such as sha1sum /home/Tianzi/xubuntu14.04.1.iso, the output is divided into two parts, the first part is the sha1 value of this file, and the second is the file path. name.

Method for verifying multiple files at the same time: sha1sum [file1] [file 2] [file 3]. . . For example, the output format such as sha1sum /home/Tianzi/xubuntu14.04.1.iso /home/tianzi/xubuntu13.10.iso is a branch, and each line corresponds to a file, which is the same as a single check

The verification result is stored in a text file: sha1sum [file 1] [file 2] "> [text file], for example:

sha1sum /home/Tianzi/xubuntu14.04.1.iso /home/tianzi/xubuntu13.10 .iso 》 /home/tianzi/sha1.txt (rebuild if the text file already exists, it will be re-created)

The verification result will continue to be written to the existing text file: sha1sum [file1] [file 2] 》》[Text file], for example:

sha1sum /home/Tianzi/xubuntu14.04.1.iso /home/tianzi/xubuntu13.10.iso 》 /home/tianzi/sha1.txt (if text file Already exists to continue writing after the text, will not overwrite the source file)

Read the information from the file to confirm the verification result: This process is more complicated, the command is simple sha1sum --check [text file], text file The content format is as follows:

SHA1 value file 1 way

SHA1 value file 2 path

The content of the command is compared according to the path of each file in the text file and the corresponding input sha1 value, if the sha1 value recorded in the text file and the sha1 of the file Consistent, then return OK, otherwise the prompt file does not match.

The above is the way to verify SHA1 and MD5 in Linux system. Users can check the integrity of the file by referring to the method described above.

Copyright © Windows knowledge All Rights Reserved