The md5sum command is used to calculate the hash value of a file or standard input using the MD5 hash function. You can also use the -c option to specify a file containing MD5 hashes and the file names they apply to; md5sum will calculate the hashes of the files listed, and then compare them to the hash values listed. The results will let you know if each file passed, failed, or could not be found.
MD5 hashes are 128-bits in length. Like many other hash values, they are typically represented in hexadecimal format (32 characters for MD5). The following is the hash value of the string “Linux”:
edc9f0a5a5d57797bf68e37364743831
Syntax
The syntax of the md5sum command is:
# md5sum [options] [file name]
md5sum Command Examples
1. Calculate the MD5 checksum for a file:
# md5sum path/to/file
2. Calculate MD5 checksums for multiple files:
# md5sum path/to/file1 path/to/filen2
3. Calculate a MD5 checksum from the standard input:
# echo "text" | md5sum
4. Read a file of MD5SUMs and verify all files have matching checksums:
# md5sum --check path/to/file.md5
5. Only show a message for missing files or when verification fails:
# md5sum --check --quiet path/to/file.md5
6. Only show a message for files for which verification fails, ignoring missing files:
# md5sum --ignore-missing --check --quiet path/to/file.md5