What is a checksum?
A checksum is a short code made from the contents of a file. Think of it as a fingerprint. If even one tiny part of the file changes, the fingerprint changes. The tool that makes it is called a hash function. Common ones are MD5, SHA-1 and SHA-256. SHA-256 is the safer choice. MD5 and SHA-1 are older and fine only for simple damage checks.
People use checksums to check that a download is complete, that a backup copied well, or that a file was not tampered with.
On Linux or Mac
- Open the terminal.
- Go to the folder with the file:
cd ~/Downloads
This moves you to the Downloads folder.
- Make a SHA-256 checksum:
sha256sum myfile.zip
This prints a long code and the file name. On a Mac, use shasum -a 256 myfile.zip.
- For MD5, use:
md5sum myfile.zip
This prints the MD5 code. On a Mac the command is md5 myfile.zip.
On Windows
- Open PowerShell from the Start menu.
- Go to the folder:
cd $HOME\Downloads
- Run:
Get-FileHash myfile.zip -Algorithm SHA256
This prints the SHA-256 code. Change SHA256 to MD5 if you need MD5.
Compare with the one you were given
- Find the checksum on the website where you got the file.
- Compare it with the code you made. They must match exactly, letter by letter.
- If they match, the file is complete and unchanged.
- If they differ, download the file again.
Check many files at once
- Make a list on Linux:
sha256sum file1.zip file2.zip > checksums.txt
This saves the codes in a text file.
- Later, check them:
sha256sum -c checksums.txt
This prints OK for each file that still matches.
Use it with your website
After you move a site or a backup, make a checksum before and after. If they match, the copy is perfect. You can do this over SSH on your hosting server if your plan allows SSH. If you are not sure, open a support ticket.
Quick recap
- A checksum is a fingerprint of a file.
- Use
sha256sumon Linux andGet-FileHashon Windows. - Same code means same file.
- Prefer SHA-256 over MD5.