2021-01-04 IBU UniBe
1
How to generate MD5 checksums and use them to check the integrity
of transferred data
What is a MD5 checksum?
MD5 checksum is a hash function producing a 128-bit hash value. It is widely used in the software
world to provide some assurance that a transferred file has arrived intact.
Linux or Mac:
How to generate an md5 checksum on Linux or Mac
1) open a terminal
2) navigate to the location where the file (some_file.txt) for which you want to generate an
md5 checksum is located
3) type the following command: md5sum some_file.txt > checkmd5.md5
4) to check the content of checkmd5.md5 run: cat checkmd5.md5
you will see something like this:
ee1ee0ab262121c0f9e79f28a76ec8dc some_file.txt
Check integrity of a file using a provided md5 checksum on Linux or Mac
my_large_file.txt: the file that you downloaded and whose integrity you want to check
checkmd5.md5: a file that contains the md5 checksum of my_large_file.txt. It is usually provided by the
party that generated my_large_file.txt (e.g. the sequencing core facility). The file name can differ,
and it can be opened using a text editor, e.g. notepad. In this example, the content of checkmd5.md5
is:
c4c4cb1b8bf1cbd4f112f0bf88a7aeb3 my_large_file.txt
To check if my_large_file.txt is ok after you downloaded it to your computer:
1) open a terminal
2) navigate to the location (the folder) where both files (my_large_file.txt and checkmd5.md5) are
stored
3) type the following command: md5sum -c checkmd5.md5
If my_large_file.txt is ok you will get this message:
my_large_file.txt: OK
If my_large_file.txt is incomplete or corrupted, you will get this message:
my_large_file.txt: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match