While working with remote files every now and then, you probably want to check file
integrity.
Checksums are the solution.
A checksum is a number that serves as a sum of correct digits in data, and which can be
used to detect errors that have occurred during file storage or transmission.
The idea is that based on the content of your file, you should always be able to calculate
the exact same checksum.
MD5 sums or SHA sums are commonly used as a checksum on Linux.
Even if MD5 is considered broken, for simply verifying file downloads, it can still be
used.
And if more security is needed, you use either SHA-256 or SHA-512, where SHA-512 is giving
the better security.
Use the MD5 sum on any file to calculate that file's MD5 checksum, and SHA sum to calculate
the file's SHA checksum.
The tab represents the number that you want to use in the command.
And to use a checksum for verification, store it in a separate file and distribute it with
a file.
Let me show you.
Okay, let me demonstrate.
To start it, I'm using MD5 sum on etcpasswd.
That's showing the checksum.
And I want to write that checksum to passwd.md5.
Then I'm going to use my verification command, so md5 sum minus cpasswd md5.
And I can see that etcpasswd is okay.
And then I'm using user add lisa.
And I'm running my MD5 sum again.
And oh boy, what do we see?
One computed checksum did not match.
Why is that?
Because the content of the file has changed.
And that's exactly what the checksum is doing.
It's observing changed content.