A 10 MB test file was checked against its SHA-256 checksum and passed. One byte in the middle was then changed, out of ten million, and the check failed. The file was cut short by a megabyte, as an interrupted download would be, and the check failed again. That is what a checksum is good at. The other half of the story is a checksum file that an attacker edited to match a tampered download, which a plain checksum cannot catch at all and a signature can. Every command was run on Linux with GNU coreutils 9.4 and GnuPG 2.4.4, and the output shown is what they printed.
What a SHA-256 checksum is
A fingerprint of the exact bytes
SHA-256 reads every byte of a file and produces a 256-bit value, written as 64 hexadecimal characters. Change any byte and the value changes completely. Projects publish the expected value next to their downloads, often in a file named SHA256SUMS, so anyone can compute the value of what they actually received and compare.
Microsoft’s documentation for PowerShell’s equivalent tool describes the idea in plain terms: a hash value corresponds to the content of the file, rather than to its name, extension or other designation.
How different “different” is
The test measured it. The original 10 MB file hashed to a value beginning bae568defd1c3074. With one byte changed in the middle, the hash began b8f48b84cb29a844. Across the full value, 62 of the 64 hexadecimal characters differed, and 128 of the 256 bits, exactly half, which is what a well-behaved hash should do: a tiny change in input scrambles about half the output bits. Two hashes that look “close” mean nothing; two hashes are either identical or the files are different.
That is also why only the full value counts. Checking the first and last few characters, a common shortcut when comparing by eye, would have caught this particular change, but it gives up most of the protection the hash exists to provide. Letting sha256sum -c compare all 64 characters costs nothing.
Why not MD5
The test printed hash lengths for the same file: 32 hexadecimal characters for MD5, 40 for SHA-1, 64 for SHA-256. Length is not the real issue. The GNU coreutils manual says MD5 is reliable for detecting accidental corruption but should not be considered secure against malicious tampering, because it is known how to modify certain files so that they appear valid under an MD5 digest. It recommends SHA-2, SHA-3 or BLAKE2 instead. SHA-256 is part of the SHA-2 family.

Checking a file on Linux
One file, by eye
sha256sum app.tar.gz prints the hash and the file name. Comparing 64 characters by eye is error-prone, so the better habit is to let the tool compare.
sha256sum -c
Given a checksum file, -c reads each line, hashes the named file and reports:
$ sha256sum -c SHA256SUMS
app.tar.gz: OK
$ echo $?
0
The test then overwrote a single byte at the 5-millionth position:
$ sha256sum -c SHA256SUMS
app.tar.gz: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
$ echo $?
1
A copy cut short at 9 MB of its 10 failed the same way. The exit status is what a script should test: 0 for a match, nonzero otherwise.
Checking against a pasted hash
When a project shows the hash on a web page instead of in a file, the hash and file name can be fed to -c on standard input:
$ echo "bae568defd1c... app.tar.gz" | sha256sum -c -
app.tar.gz: OK
The standard format has two spaces between hash and name. In the test, coreutils 9.4 also accepted a single space and a hash pasted in uppercase. Older versions or other tools may be stricter, so two spaces and lowercase are the safe form.
Checksum files with many entries
–ignore-missing
Release directories usually publish one SHA256SUMS covering every file, and most people download only one. Checking the whole list then complains about the rest:
other.iso: FAILED open or read
sha256sum: WARNING: 1 listed file could not be read
app.tar.gz: OK
The coreutils manual describes --ignore-missing as telling the checker don’t fail or report any status for missing files, which it notes is useful when verifying a subset of downloaded files against a larger list. With it, the test printed only app.tar.gz: OK.
–strict
The same page lists --strict, which makes the check exit nonzero if any line of the checksum file is malformed, after all warnings are printed. For automated checks, where a corrupted checksum file should never be read as a pass, it is worth adding.

What a checksum does not prove
The attacker who edits both files
A checksum proves that the file matches the hash next to it. It does not prove who wrote the hash. If an attacker can replace the download on a server, they can usually replace SHA256SUMS on the same server, and the check will pass on the tampered file.
The test showed the defense. A signing key was created, the checksum file was signed with a detached signature, and the signature was checked:
$ gpg --verify SHA256SUMS.asc SHA256SUMS
gpg: Good signature from "Release Signing <release@example.test>"
Then one character of the hash in SHA256SUMS was changed, standing in for an attacker who had swapped the file and updated the checksum to match:
gpg: BAD signature from "Release Signing <release@example.test>"
The attacker could change the checksum. Without the private key, they could not produce a new valid signature for it.
How a real project does it
Ubuntu’s own tutorial on verifying its downloads follows exactly this pattern. It has the user run gpg –keyid-format long –verify SHA256SUMS.gpg SHA256SUMS, and explains that if the signing keys are not already present, the error message names the key IDs to fetch from the Ubuntu key server. It then shows the expected key fingerprints so the user can compare them. The tutorial uses GnuPG’s long 64-bit key IDs and notes that short 32-bit IDs are insecure.
The order of operations matters: verify the signature on the checksum file first, then use the now-trusted checksum file to verify the download. A checksum checked against an unsigned list from the same server is a corruption check, not a security check.
Checksums for your own files
A manifest for a backup
The same tool works in reverse: record checksums for files that matter now, and check them later. Backups, archives and photo libraries can be damaged without any error at the time, and a manifest is how that damage becomes visible. The test made five 200 KB files, recorded them, then damaged one and deleted another:
$ cd photos && sha256sum *.jpg > ../photos.sha256
... one byte of img3.jpg changed, img5.jpg deleted ...
$ sha256sum -c --quiet ../photos.sha256
img3.jpg: FAILED
img5.jpg: FAILED open or read
sha256sum: WARNING: 1 listed file could not be read
sha256sum: WARNING: 1 computed checksum did NOT match
--quiet suppressed the OK lines, so only problems printed: the one-byte change and the missing file, nothing about the three good files. The exit status was 1. Run on a schedule, that is a complete integrity check for a folder in two commands.
Two details from the test matter in practice. The manifest stores file names as given, so it was made from inside the folder and must be checked from inside it; recording paths from the parent works too, as long as checking happens from the same place. For a whole tree, find photos -type f -exec sha256sum {} + | sort -k2 produced one sorted manifest covering every file below the folder.
The tagged format
Newer coreutils also provide cksum -a sha256, which writes a tagged line naming the algorithm:
SHA256 (photos/img1.jpg) = 4f845f061fd48...
cksum -c checked that file and printed photos/img1.jpg: OK. Because each line says which algorithm produced it, a tagged manifest cannot be accidentally checked with the wrong tool, which is a small but real advantage for files kept for years.

On Windows and macOS
Get-FileHash
PowerShell’s Get-FileHash does the same job. Microsoft’s documentation says that by default it uses the SHA256 algorithm, so Get-FileHash .\app.zip prints the SHA-256 value with no extra options. Comparing it against the published value is then a string comparison, which PowerShell can do with -eq rather than by eye.
macOS
macOS ships shasum, which takes -a 256 for SHA-256 and also supports -c with a checksum file in the same two-space format.
When to bother
Always for anything that runs with privileges
Operating system images, installers, firmware and anything piped into a shell deserve a signature check where the project offers one, and at least a checksum where it does not. For a large file downloaded over an unreliable connection, a checksum is the fastest way to know the copy is complete before spending an hour installing from it. On the test file, hashing 10 MB took under a hundredth of a second; there is no performance reason to skip it.
Sources
- md5sum invocation, GNU Coreutils manual: https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html
- cksum common options, GNU Coreutils manual: https://www.gnu.org/software/coreutils/manual/html_node/cksum-common-options.html
- How to verify your Ubuntu download, Ubuntu tutorials: https://ubuntu.com/tutorials/how-to-verify-ubuntu
- Get-FileHash, Microsoft Learn: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash

[…] early if it is damaged. A published checksum is the stronger check, covered in the earlier post on verifying downloads with sha256sum. For moving archives between machines, the earlier post on scp, rsync and sftp applies; […]