In this tutorial, we will learn how to use the md5sum command to calculate the footprint of a file or, rather, of a message to use the term adapted to this context. For information, a fingerprint is used to calculate and verify the integrity of a file or data. If we take the same file in two versions but with only one bit of difference, its footprint will be totally different!
If a file no longer has the same footprint after being transferred from machine A to machine B, this calls into question its integrity. What happened? The file may have been corrupted intentionally or accidentally. For example, the file may have become corrupted due to LAN-related packet loss. Conversely, if the fingerprint is still the same, it means that the file is strictly identical to the original file: its integrity has been preserved.
For example, when downloading a file from the Internet, it is common to see the file’s fingerprint, either MD5, SHA1, or SHA256. This reference value allows you to check the file’s integrity after downloading. Today, MD5 can still be used to verify the integrity of a file after it has been downloaded. However, for other security-related uses, MD5 is obsolete and should be abandoned in favor of more secure methods like SHA256.
II. Using the md5sum command
Natively integrated into Linux, the md5sum command will allow you to calculate the fingerprint of a file via the MD5 function.
For example, if we want to calculate the footprint of the “linux.txt” file, we will use the command like this:md5sum linux.txt
We will then have the fingerprint of this file as a result:
The returned value corresponds to the MD5 fingerprint of the file, which is also called ” checksum ” or ” checksum “.
If you make the slightest modification in this file, for example, by adding a character, the checksum will no longer be the same:
We can also store this fingerprint in a file so that users can compare it again:md5sum linux.txt > Linux. checksum
You can also do a checksum of several files to be able to compare them easily:md5sum linux.txt linux2.txt
Here, it is a copy and paste of the original file under another name: its content is not altered, so the fingerprint remains the same! This is important: the fingerprint is based on the file’s contents, not its name.