Monday, August 22, 2022

How to check MD5 checksum of any downloaded file in Linux

 What is MD5 Sum?


An MD5 checksum is a mathematical algorithm is usually a set of 32-character hexadecimal letters and numbers that are computed on a file with a tool. These numbers are generated using special tools that employ “cryptographic hash function producing a 128-bit (16-byte) hash value”. It is used not only to encrypt a ZIP archive or an EXE installer but all kinds of files. You can assign an MD5 sum even to a text or document file. The perfect match of MD5 checksum value ensures that the digital integrity and security of a file has not been broken by someone else and also that it is the accurate copy of the original file.

Thus, there are the two main reasons if the MD5 hash value of a file you downloaded does not match against the original sum:

The file might be modified by someone else in an unauthorized way.
The file was not downloaded properly and some of its elements might have been corrupted.

Here's an example of what the MD5 checksum or hash value of a file might look like: 25912deacc5d55528e223ec7b99705cc

From Wikipedia:
" The MD5 message-digest algorithm is a cryptographically broken but still widely used hash function producing a 128-bit hash value. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities. It can still be used as a checksum to verify data integrity, but only against unintentional corruption. It remains suitable for other non-cryptographic purposes, for example for determining the partition for a particular key in a partitioned database, and may be preferred due to lower computational requirements than more recent Secure Hash Algorithms."


Steps to compare the MD5 checksum value in Linux:

  1. Open a terminal window.
  2. Type the following command:
    md5sum [type file name with extension here] [path of the file] -- NOTE: You can also drag the file to the terminal window instead of typing the full path.
    Example:
    $md5sum /home/mukesh/test/testfile.cpp
    output: 
    c6779ec2960296ed9a04f08d67f64422  /home/mukesh/test/testfile.cpp
    
  3. Hit the Enter key.
  4. You’ll see the MD5 sum of the file. 
  5. Match it against the original value.

No comments:

Post a Comment