This post is mostly about Security Hash Algoritms and how you can use them to verify the integrity of your files.
SHA1
Let’s say you downloaded something. The website had a sha1sum there and you want to verify that you actually got the file you wanted – and not some tampered malware. Checking is as easy as writing:
sha1sum <filename> .
Or if you want to verify a checksum even more easily, pipe it and use grep.
sha1sum <filename> | grep <checksum_listed_on_the_page> .
If you get the hash as an output that usually means that things are ok. If you get nothing then there is a mismatch.
SHA256
SHA1 is deprecated and vulnerable these days and most of the times SHA256 is being used – since it provides better security.
To check sha256sums just replace the beginning with sha256sum:
sha256sum <filename>
sha256sum <filename> | grep <checksum_listed_on_the_page>
Again, If you get the hash as an output that usually means that things are ok. If you get nothing then there is a mismatch.
What about MD5?
MD5 used to be a popular alternative to SHA2 family. The commands are easy to use as well;
md5sum <filename>
md5sum <filename> | grep <checksum_listed_on_the_page>
Yet again, If you get an output that usually means things are ok. If you get nothing then there is a mismatch.
MD5 has had trouble with its underlying security. You can still use MD5 for basic checking but these days it is recommended that you should use something like sha256sum instead.