Linux · Command Line

    How to Verify Checksums on Linux (sha256sum & md5sum)

    sha256sum and md5sum are the quickest way to verify a file on Linux. Here's how to hash, check downloads, and checksum a folder from the terminal — and the one gap (newly added files) that plain check mode quietly misses.

    Published June 30, 20269 min read
    Mehrab Ali

    Author

    Mehrab Ali

    Data Scientist, Researcher & Entrepreneur

    Founder of ARCED Foundation, ARCED International, and Solutions of Things Lab (SoTLab). Built FolderManifest to help teams protect file integrity and stay audit-ready.

    Quick answer

    To verify a file on Linux, run sha256sum file.iso to print its SHA-256 hash, or check it against a published value with sha256sum -c file.iso.sha256 (prints file.iso: OK). Both tools are in GNU coreutils, so they're already installed. To checksum a folder, pipe find into sha256sum — but note that -c catches modified and missing files, not newly added ones.

    • sha256sum file → hash; -c verifies against a saved list.
    • md5sum is faster but broken — use sha256sum for integrity.
    • find . -type f -print0 | xargs -0 sha256sum hashes a whole tree.
    • For real folder verification (incl. added files) use a manifest.

    Hash a file

    sha256sum is part of GNU coreutils and present on essentially every Linux distribution. Give it a filename and it prints the hash followed by the name:

    Terminal
    sha256sum ubuntu.iso
    9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08  ubuntu.iso

    The two spaces between the hash and the filename are part of the format — the first space marks text mode, and a * there would mark binary mode. Want only the digest, with no filename? Cut the first field:

    Terminal
    sha256sum ubuntu.iso | cut -d' ' -f1

    md5sum vs sha256sum

    They're siblings: same interface, different algorithm. md5sum is faster and fine as a quick non-security checksum, but MD5 is cryptographically broken — a malicious file can be crafted to match a given MD5. For anything where tampering matters, use sha256sum.

    Terminal
    md5sum ubuntu.iso
    # d41d8cd98f00b204e9800998ecf8427e  ubuntu.iso   (fast, but not tamper-proof)
    
    sha256sum ubuntu.iso
    # 9f86d081...0f00a08  ubuntu.iso                 (the secure default)

    The full trade-off — speed numbers, collision resistance, and when each is acceptable — is in MD5 vs SHA-256. Short version: reach for sha256sum unless you have a specific reason not to.

    Verify a download with check mode (-c)

    The cleanest way to confirm a download is the built-in check mode. Save the published hash and filename to a .sha256 file, then let sha256sum -c re-hash and compare:

    Terminal
    # the published hash, saved exactly as "hash␠␠filename"
    echo "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08  ubuntu.iso" > ubuntu.iso.sha256
    
    sha256sum -c ubuntu.iso.sha256
    ubuntu.iso: OK

    A mismatch prints ubuntu.iso: FAILED and a warning summary. You can also skip the file and pipe the expected line straight in:

    Terminal
    echo "9f86d081...0f00a08  ubuntu.iso" | sha256sum -c -

    Checksum a whole folder

    sha256sum takes many files at once, so combine it with find to hash an entire tree into a single manifest. Use -print0/-0 so paths with spaces survive:

    Terminal
    # build a manifest of every file under ./project
    find ./project -type f -print0 | xargs -0 sha256sum > project.sha256
    
    # later, verify nothing in the manifest changed
    sha256sum -c project.sha256
    ./project/report.pdf: OK
    ./project/data.csv: OK
    ./project/config.yml: FAILED

    That's a genuine integrity check for the files you recorded — and it's reproducible and free. For many jobs it's all you need.

    The gap: -c ignores added files

    Here's the subtle trap. sha256sum -c only checks the lines in the manifest. It will flag a modified file (FAILED) and a deleted one (No such file or directory) — but a brand-new file dropped into the folder simply isn't in the manifest, so it's silently ignored.

    Folder changesha256sum -cA folder manifest
    File modifiedDetected (FAILED)Detected
    File deletedDetected (missing)Detected
    File addedMissedDetected

    For untrusted folders — anywhere an extra file is exactly what you'd worry about — that blind spot matters. Closing it means comparing the whole snapshot, not just a list of expected hashes.

    Verify folders repeatably (additions included)

    The FolderManifest CLI runs on Linux and treats the folder as a whole. Generate a SHA-256 baseline once:

    Terminal
    foldermanifest generate ./project --format json --out project-baseline

    Then verify against it. Because it compares the full snapshot, it catches additions, deletions, and modifications — and exits 0 for unchanged, 1 for drift, so it slots into a cron job or CI step without parsing output:

    Terminal
    foldermanifest verify ./project --manifest project-baseline.json
    echo "exit: $?"   # 0 = unchanged, 1 = something was added/removed/modified

    To run it on a schedule with cron and alert only on drift, see automating folder verification. On Windows? The same idea with PowerShell Get-FileHash.

    From sha256sum to whole-folder verification

    The FolderManifest CLI ships inside the desktop app on Linux and Windows — included with the 7-day trial and every lifetime license. Keep sha256sum for one-offs; verify the whole tree with one command.

    Frequently asked questions

    How do I check a SHA-256 checksum on Linux?
    Run sha256sum file.iso to print the hash, or verify against a published value with the check mode: echo "<hash> file.iso" | sha256sum -c, which prints "file.iso: OK" when the file matches. Most distributions ship sha256sum in GNU coreutils, so nothing extra is needed.
    What is the difference between sha256sum and md5sum?
    They are the same tool family for different algorithms. md5sum computes the faster but cryptographically broken MD5 digest; sha256sum computes SHA-256, which has no practical collision attack. Use sha256sum for anything security- or tamper-sensitive, and treat md5sum as a quick non-security checksum only.
    How do I verify a downloaded file with sha256sum?
    Save the published hash and filename to a .sha256 file, then run sha256sum -c file.iso.sha256. It re-hashes the file and prints OK or FAILED. Alternatively pipe the expected line directly: echo "<hash> file.iso" | sha256sum -c. Two spaces between the hash and the filename are required by the format.
    How do I checksum an entire folder on Linux?
    Combine find with sha256sum: find . -type f -print0 | xargs -0 sha256sum > manifest.sha256. To verify later, run sha256sum -c manifest.sha256. This catches modified and missing files, but it does NOT report files that were newly added to the folder — a real gap for true folder verification.
    Does sha256sum -c detect new files added to a folder?
    No. sha256sum -c only checks the files listed in the manifest. If someone adds a new file, it will not appear in the manifest and -c will silently ignore it. To detect additions as well as modifications and deletions, you need a tool that compares the full folder snapshot, not just a list of expected hashes.
    Why are there two spaces in a sha256sum file?
    The coreutils format is "hash" + two spaces + "filename". A single space (text mode) or a space-asterisk (binary mode) also appear in some files. If you build the line by hand for sha256sum -c, use two spaces or the check will fail to parse the entry.
    How do I verify a whole folder repeatably on Linux?
    Generate a SHA-256 manifest of the folder once with the FolderManifest CLI, then run verify against it. verify exits 0 when the folder matches and 1 when any file was added, removed, or modified — including additions, which a plain sha256sum -c misses. The stable exit code works directly in cron jobs and CI.

    Related: MD5 vs SHA-256 · PowerShell Get-FileHash · Automate folder verification