When you are downloading files or transferring data, it is important to ensure that you keep their integrity and authenticity intact. A corrupt file will most definitely lead to unexpected errors, security risks, and even system compromise.
In command, MD5SUM in Linux is one such command that generates and verifies MD5 (Message Digest 5) checksums, also known as the unique fingerprints of files. By comparing these checksums to each other, you can confirm if the file is unchanged or corrupted.
In this guide, we shall walk through the importance of the command MD5SUM in Linux, discuss usecases, and go-through the steps to generate, verify, and compare the MD5 checksums.
Understanding MD5SUM in Linux
The MD5SUM in Linux is used to calculate the MD5 hash value of a file. In layman terms, it is a 128-bit cryptographic checksum that represents the unique value of a fingerprint in a file. If there is even a slight change in a file, for example a character change, the resulting hash will be completely different.
This makes md5sum a simple yet fool-proof method to check the file integrity after downloads, transfers, or backups.
So, what is an MD5 Hash?
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
MD5 is a hashing algorithm that converts the input data into a 32-character hexadecimal string. It is deterministic, which means that the same input will always generate the same hash value. MD5 hashes are often included on websites hosting software downloads to verify authenticity.
Example:
echo “Linux” | md5sum
How Does md5sum Work in Linux?
The md5sum command:
- Read the file’s contents.
- Processes it through the MD5 algorithm.
- Outputs a 32-character hash alongside the file name.
Example:
md5sum file.iso
You can then compare this hash by the file source to ensure that there is no corruption or tampering.
Common Use Cases for md5sum
A few of the most common use cases for md5sum Linux command are:

- Verifying downloaded files.
- Detecting corrupt files by spotting changes by disk errors or transmission issues.
- Checking file integrity after transfer.
- Using automation in scripts for backup and validation.
Related Article: Solus Linux: A Beginner-Friendly and Independent Linux Distribution
How to Check MD5SUM in Linux
The md5sum utility is available by default on almost all Linux distributions, which you can use to verify the MD5 checksums. Some of the command ways to check MD5SUM in Linux are:
Generating an MD5 Checksum for a File
First create an MD5 checksum for a file by running:
md5sum filename
Example:
md5sum myfile.txt
You would get an output like this:
098f6bcd4621d373cade4e832627b4f6 myfile.txt
Here:
- 098f6bcd4621d373cade4e832627b4f6 → the MD5 hash.
- myfile.txt → the file name.
You can also generate a checksum for multiple files:
md5sum file1.zip file2.iso
Verifying a File with MD5SUM
If you have a file ready with its MD5 checksum, you can verify it by running:
- Save the provided checksum into a file, e.g., checksum.md5.
098f6bcd4621d373cade4e832627b4f6 myfile.txt - Run: md5sum -c checksum.md5
- If the file has been altered or corrupted, you’ll see: myfile.txt: FAILED
Comparing Multiple Files Using MD5SUM
You check if two files are identical by comparing their MD5 hashes.
md5sum file1.txt file2.txt
If both hashes match, the files are identical.
If they differ, you’ll get different hashes.
Using MD5SUM with Downloaded Files
When downloading files like ISO images or software packages, developers will usually provide an .md5 file with the download.
Example workflow:
- Download the file and its .md5 checksum file.
wget https://example.com/linux.iso
wget https://example.com/linux.iso.md5
- Verify the file:
md5sum -c linux.iso.md5 - Manual check if no .md5 file is given:
md5sum ubuntu.iso
This ensures the file is complete and unaltered before you install or use it.
Then compare the generated hash with the one provided on the download site.
Practical Examples of md5sum in Linux
Here are some real-world use cases:
Use Case | Example Command | Purpose |
Verify a backup file | md5sum backup.tar.gz | Ensure backup integrity |
Compare two files | md5sum file1.txt file2.txt | Check if files are identical |
Automate verification in a script | md5sum *.iso > checksums.md5 | Generate checksums for multiple files at once |
Verify multiple files later | md5sum -c checksums.md5 | Quickly validate all listed files |
Detect accidental corruption | md5sum video.mp4 | Confirm file wasn’t corrupted during transfer |
Limitations of MD5SUM in Linux
While the md5sum is useful, it has some important limitations that you must remember:
- MD5 is vulnerable to collision attacks, which means that two files can have the same hash even if they have different content.
- It is not recommended for vulnerable and sensitive information like password storage or digital signatures.
- There are better alternatives that you can explore to avoid security breaches, like sha256sum or sha512sum.
Conclusion – Using MD5SUM in Linux
The md5sum command is useful when testing the hashes for downloaded files, validating backups, or comparing files. But it should be avoided when dealing with sensitive information and critical tasks.
FAQs
Is MD5SUM secure for file verification?
MD5 is suitable for basic integrity checks but is not cryptographically secure. For stronger verification, consider SHA256SUM or SHA512SUM.
Why is MD5SUM used with downloaded files?
Developers often provide MD5 checksums with downloads so users can verify that the file hasn’t been corrupted or tampered with.
How do I check the MD5SUM of a file in Linux?
Run the command: md5sum filename
This will display the MD5 hash of the file.