Xerobit
Dev Productivity

Verify a File Checksum: Linux, macOS, Windows and CI

Copy-paste commands to verify a SHA-256 checksum on Linux, macOS and Windows, the exact OK and FAILED output, why checksum files break, and how to fail a CI build on mismatch.

MA Mian Ali Khalid Updated Nov 2, 2026 7 min read
Free tool
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes client-side.
Open tool →
On this page ⌄
  1. The fast path
  2. Hash a string and a file, then match the Hash Generator
  3. Why a checksum file fails: error table
  4. A checksum next to the download proves little
  5. Fail a CI build on mismatch
  6. Which algorithm
  7. FAQ
  8. Tested

You downloaded app-1.0.tar.gz and the release page lists a SHA-256 hash. This guide shows the exact command for each OS, what success and failure look like, the four ways a checksum file silently breaks, and how to make CI fail when a download does not match. All outputs were produced on 2026-11-02.

The fast path

Linux (GNU coreutils), with the publisher's SHA256SUMS file next to the download:

sha256sum -c SHA256SUMS
app-1.0.tar.gz: OK

If one byte differs:

app-1.0.tar.gz: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match

The exit code is 0 on success and 1 on any failure, so it works in scripts. The second output was produced by changing one byte of a 1 MiB file.

macOS ships shasum, not sha256sum:

shasum -a 256 -c SHA256SUMS
shasum -a 256 app-1.0.tar.gz     # print the hash instead of checking

It prints the same app-1.0.tar.gz: OK. The Perl shasum script, which is what macOS provides, was run on a Windows machine and not on macOS hardware.

Windows PowerShell has no -c mode, so compare the hash yourself:

$expected = "4e29ad18ab9f42d7c233500771a39d7c852b200baf328fd00fbbe3fecea1eb56"
$actual = (Get-FileHash .\app-1.0.tar.gz -Algorithm SHA256).Hash
if ($actual -eq $expected) { "OK" } else { "MISMATCH" }

PowerShell 5.1 printed the hash in uppercase (4E29AD18...), and -eq on strings is case-insensitive, so the comparison above returned True against a lowercase expected value. -ceq returned False. Remember that if you compare in any other tool.

Windows Command Prompt works on every Windows version:

certutil -hashfile app-1.0.tar.gz SHA256

It prints a header, the hash in lowercase on its own line, and CertUtil: -hashfile command completed successfully.

You can also use OpenSSL: openssl dgst -sha256 app-1.0.tar.gz printed SHA2-256(app-1.0.tar.gz)= 4e29ad18... with OpenSSL 3.5.5.

Hash a string and a file, then match the Hash Generator

The Hash Generator hashes pasted text or a file in the browser using the Web Crypto API (crypto.subtle.digest). To check you are using it correctly, hash the five characters hello:

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

That is what printf 'hello' | sha256sum printed, and what crypto.subtle.digest('SHA-256', ...) returned in Node. Now the classic trap: echo hello | sha256sum hashes six bytes, because echo appends a newline, and gives a different value:

5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03

If the text you paste into a hash tool does not match your shell, a trailing newline is the first suspect. Use printf or echo -n. For a downloaded file there is no such issue: drop it into the tool, or run sha256sum file, and compare the two strings. MD5 for hello is 5d41402abc4b2a76b9719d911017c592, which is still fine for catching corruption but not for detecting tampering.

Why a checksum file fails: error table

What you seeCauseFix
sha256sum: bare.sha256: no properly formatted SHA256 checksum lines foundThe file contains only the hash, with no filenameUse the form HASH filename: echo "HASH app-1.0.tar.gz" | sha256sum -c -
sha256sum: 'app-1.0.tar.gz'$'\r': No such file or directory, then FAILED open or readThe checksum file has Windows (CRLF) line endings, so the filename is read as app-1.0.tar.gz\rtr -d '\r' < SHA256SUMS | sha256sum -c - or run dos2unix
nofile.bin: FAILED open or readThe filename in the list is not in the current directorycd to the download directory, or edit the path
app-1.0.tar.gz: FAILED but the hashes look the sameDifferent file than the publisher hashed (a different version, an HTML error page saved as the file, or an interrupted download)Re-download; check the size
Hash looks different only in casePowerShell's Get-FileHash prints uppercase, certutil and sha256sum lowercaseGNU sha256sum -c accepts uppercase hex (tested); for manual compares lowercase both sides
hash *file vs hash file* means binary mode, two spaces means text modeBoth verified OK with GNU sha256sum; the mode makes no difference there, only on systems that translate line endings

On GNU coreutils, the line format is the hash, then two spaces, then the filename. The * form appears when the tool defaults to binary mode (it did in Git Bash on Windows); sha256sum --text printed the two-space form and the same hash.

A checksum next to the download proves little

If an attacker can replace app-1.0.tar.gz on a server, they can usually replace the SHA256SUMS file beside it too. A checksum from the same place only protects against accidental corruption. For authenticity you need the checksum to be signed, or published somewhere else you trust (a signed release, a package manager lock file, a different domain).

Signed checksums use GPG. Publishers sign the list, and you verify the signature first and the files second. A throwaway key was generated:

gpg --armor --detach-sign SHA256SUMS     # publisher: creates SHA256SUMS.asc
gpg --import release.pub.asc             # you: import the publisher's public key
gpg --verify SHA256SUMS.asc SHA256SUMS

On a machine that has imported the public key, the output was:

gpg: Signature made Mon Nov  2 21:42:37 2026 PST
gpg:                using EDDSA key EA5F3DA7DCC5C22ECCF07CF7030ADC8A68D0B630
gpg: Good signature from "Example Release <release@example.invalid>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: EA5F 3DA7 DCC5 C22E CCF0  7CF7 030A DC8A 68D0 B630

That warning is normal and important. "Good signature" means the file was signed by whoever holds that key, not that the key is the publisher's. Compare the fingerprint with one published on a separate, trusted channel before you rely on it. Other results:

  • A modified SHA256SUMS gave gpg: BAD signature from ... and exit code 1.
  • Without the public key imported: gpg: Can't check signature: No public key and exit code 2.

A safe script chains both checks: gpg --verify SHA256SUMS.asc SHA256SUMS && sha256sum -c SHA256SUMS, which printed app-1.0.tar.gz: OK in testing.

Fail a CI build on mismatch

Pin the expected hash in your repository, not in the same download location, and let sha256sum -c - set the exit code. A GitHub Actions step (YAML parsed successfully; the sha256sum line was run locally and returned OK for the right hash and FAILED, exit 1, for a wrong one):

- name: Download and verify
  env:
    TOOL_SHA256: 4e29ad18ab9f42d7c233500771a39d7c852b200baf328fd00fbbe3fecea1eb56
  run: |
    curl -fsSLO https://example.com/app-1.0.tar.gz
    echo "${TOOL_SHA256}  app-1.0.tar.gz" | sha256sum -c -

GitHub Actions runs run blocks with bash -e, so a non-zero exit from sha256sum stops the job. The same pattern works inside a Dockerfile:

RUN curl -fsSLo /tmp/app.tar.gz https://example.com/app-1.0.tar.gz \
 && echo "4e29ad18ab9f42d7c233500771a39d7c852b200baf328fd00fbbe3fecea1eb56  /tmp/app.tar.gz" | sha256sum -c -

This Dockerfile was not built; it uses the same sha256sum line as above.

Use two spaces between the hash and the filename, and quote the echo argument so the shell does not collapse them.

Which algorithm

Use SHA-256 unless the publisher gives you something else. MD5 and SHA-1 detect accidental corruption but have known collision attacks, so a matching MD5 does not prove a file is the one the author published. If you only have an MD5, md5sum -c works the same way, and Get-FileHash -Algorithm MD5 on Windows. You can check any value against a quick text or file hash in the Hash Generator.

FAQ

How do I verify a SHA-256 checksum on Windows? (Get-FileHash .\file -Algorithm SHA256).Hash in PowerShell, or certutil -hashfile file SHA256 in Command Prompt, then compare with the published value.

What does "no properly formatted checksum lines found" mean? The file you gave to sha256sum -c is not in HASH filename format, usually because it holds only the hash. Add the filename.

Why does sha256sum say FAILED open or read? It cannot find the listed file, often because of a CRLF line ending or a wrong directory.

Is it safe to trust the checksum on the download page? Only against accidental corruption. Verify a signature or use a hash from a separate trusted channel.

Can I check a hash without the command line? To hash a file in your browser use the Hash Generator. For pasted text, the SHA-256 Hash Generator and MD5 Hash Generator give the digest, and the Hash Checker compares it with a published value. For non-cryptographic checks such as CRC-32, the CRC Calculator and Checksum Calculator work on pasted text or hex.

Tested

Run on 2026-11-02: GNU coreutils sha256sum 8.32 and Perl shasum in Git Bash, Windows PowerShell 5.1.26100 (Get-FileHash), certutil, OpenSSL 3.5.5, GnuPG 2.4.9 with a throwaway key, and Node 25.8.0 Web Crypto. The Docker snippet and macOS hardware were not tested.

Related tools

Written by Mian Ali Khalid. More guides in Dev Productivity.