md5sum is a command-line utility program that calculates and verifies the MD5 (Message Digest 5) hash values of files. The MD5 hash value is a 128-bit value that is used to check the integrity of files and to verify that they have not been tampered with. The
md5sum command is commonly used to verify the integrity of downloaded files and to ensure that they have not been corrupted during the download process.
The basic syntax of the
md5sum command is as follows:
md5sum [OPTION]... [FILE]...
To calculate the MD5 hash value of a file, simply specify the file name as an argument to the
md5sum command. For example, to calculate the MD5 hash value of a file called
myfile.txt, you would run the following command:
This will output the MD5 hash value of the file in hexadecimal format, along with the file name:
To verify the integrity of a file, you can compare its MD5 hash value with the expected hash value. This is typically done by downloading the file and its associated MD5 hash value from a trusted source, and then running the
md5sum command on the downloaded file to calculate its hash value. The calculated hash value can then be compared with the expected hash value to ensure that the file has not been tampered with.
For example, suppose you have downloaded a file called
myfile.tar.gz and its associated MD5 hash value file called
myfile.tar.gz.md5. To verify the integrity of the downloaded file, you would run the following command:
md5sum -c myfile.tar.gz.md5
This will read the MD5 hash value from the
myfile.tar.gz.md5 file and compare it with the calculated hash value of the
myfile.tar.gz file. If the two hash values match, the output will indicate that the file is OK:
If the two hash values do not match, the output will indicate that the file is not OK:
md5sum command supports the following options:
||Read files in binary mode (default is text mode)|
||Read MD5 sums from the specified files and check them|
||Read files in text mode (default)|
||Warn about improperly formatted MD5 checksum lines|
- If the calculated hash value does not match the expected hash value, try downloading the file again from a different source.
- If the
md5sumcommand reports that a file has failed verification, it is possible that the file has been tampered with or corrupted. Try downloading the file again from a trusted source.
- If you encounter issues with the
md5sumcommand, ensure that you are using the correct syntax and options. Refer to the command’s manual page (
man md5sum) for more information.
- MD5 is a cryptographic hash function that is no longer considered secure for certain applications. For more secure hash functions, consider using SHA-256 or SHA-512.
md5sumcommand is part of the GNU Core Utilities package, which is typically included with most Linux distributions.