🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

md5sum Command

Beginner Firewall & Security man(1)

Compute and verify MD5 message digests

👁 9 views 📅 Updated: Mar 15, 2026
SYNTAX
md5sum [OPTION]... [FILE]...

What Does md5sum Do?

md5sum calculates and verifies MD5 message digests (128-bit hash). It produces a unique fingerprint of a file that can be used to verify data integrity — any change to the file produces a different hash.

md5sum is commonly used to verify downloaded files, check file integrity after transfers, and detect file modifications. However, MD5 is cryptographically broken and should not be used for security — use sha256sum instead.

MD5 is still acceptable for non-security uses like checking file integrity during transfers and deduplication.

Options & Flags

OptionDescriptionExample
file Calculate MD5 hash md5sum file.iso
-c Check hashes from file md5sum -c checksums.md5
-b Binary mode md5sum -b file.bin
--quiet Only show failures when checking md5sum --quiet -c checksums.md5

Practical Examples

#1 Calculate hash

Computes the MD5 hash of a file.
$ md5sum ubuntu.iso
Output: e8a123b456c789... ubuntu.iso

#2 Verify download

Checks all files listed in MD5SUMS against their expected hashes.
$ md5sum -c MD5SUMS
Output: ubuntu.iso: OK

#3 Compare files

Generates hashes to compare if two files are identical.
$ md5sum file1.txt file2.txt
Output: d41d8cd98f00... file1.txt\nd41d8cd98f00... file2.txt

#4 Hash a string

Calculates MD5 of a string (use -n to avoid newline).
$ echo -n "hello" | md5sum
Output: 5d41402abc4b... -

#5 Create checksum file

Generates a checksum file for all ISOs.
$ md5sum *.iso > checksums.md5

Tips & Best Practices

MD5 is not secure: MD5 is cryptographically broken — collisions can be crafted. Use sha256sum for security-critical verification.
Quick file comparison: To check if two files are identical without comparing content: md5sum file1 file2. Same hash = same content.
Use -n with echo: echo "text" | md5sum includes a newline in the hash. Use echo -n "text" | md5sum for the string without newline.

Frequently Asked Questions

How do I verify a downloaded file?
Download the MD5 checksum file, then run md5sum -c checksums.md5. It reports OK or FAILED for each file.
Is MD5 still safe to use?
For integrity checking (detecting accidental corruption): yes. For security (detecting tampering): no. Use sha256sum for security.
How do I compare two files?
md5sum file1 file2 — if both hashes are identical, the files have the same content.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →