Linux Commands / IT Support Guides
Verify Linux artifacts with sha256sum
Verify a downloaded file against a trusted SHA-256 digest before using it.
Start hands-on practice ↓When to use it
A checksum can detect a corrupted transfer or a mismatched build. Calculate it before installing an artifact or comparing copies across two systems.
Try the diagnostic command
Use the stated shell and platform. Replace sample domains, addresses, services and paths with values from the system you are authorized to support.
sha256sum -- installer.tar.gz
How to read the result
The command prints a SHA-256 digest and filename. Compare the full digest against an independently trusted publisher value or a known source copy.
What to do next
Replace the filename and record where the reference digest came from. If values differ, investigate the selected version and transfer path before using the artifact.
Before you make a change
A checksum received through the same compromised channel as the file provides limited assurance. Matching hashes do not establish publisher trust by themselves.
Practical guide
Download worksheetDetailed practical guide
Prepare your workspace and inputs
Use Bash on Linux with GNU Coreutils and write access to a temporary directory. Run the commands in order in the same shell. The exercise uses a three-byte sample file.
Platform context: Linux with Bash and GNU Coreutils
Scenario to reproduce or investigate
A release publisher gives you a SHA-256 digest for an installer. You want to check that your copy has the same bytes before opening it. Practice first with a small file and a fixed reference digest.
- Artifact name and version
- Reference source
- Initial and restored check output
- Mismatch output and exit status
-
Create a sample and its reference file
Create a fresh scratch directory, then write exactly three bytes and save the supplied digest in GNU checksum format. The two spaces before the filename are intentional.
Run in Bash
lab_dir=$(mktemp -d) && cd -- "$lab_dir" && printf 'abc' > artifact.txt && printf '%s %s\n' 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' 'artifact.txt' > SHA256SUMSExpected resultThe command exits with status 0 and creates artifact.txt and SHA256SUMS.
If it failsIf directory creation or a write fails, use a writable temporary location and repeat this step.
-
Verify the original bytes
Run the check from the directory containing artifact.txt. Relative filenames in the manifest are resolved from your current directory.
Run in Bash
LC_ALL=C sha256sum --check --strict SHA256SUMSExpected resultThe command prints artifact.txt: OK and exits with status 0.
If it failsIf the file cannot be opened, check the current directory and filename. A format error means the reference line needs to be checked against the publisher’s original.
-
Confirm that a changed file fails
Append a newline to the disposable sample and run the same check again. This simulates a change to the downloaded bytes.
Run in Bash
printf '\n' >> artifact.txt && LC_ALL=C sha256sum --check --strict SHA256SUMSExpected resultThe command prints artifact.txt: FAILED and exits with a nonzero status.
If it failsIf it still prints OK, confirm the manifest names the file you changed and that the append succeeded.
-
Restore the sample and recheck
Recreate the original three-byte sample and check it against the same reference.
Run in Bash
printf 'abc' > artifact.txt && LC_ALL=C sha256sum --check --strict SHA256SUMSExpected resultThe command prints artifact.txt: OK and exits with status 0.
If it failsIf the check still fails, start again in a fresh directory and use the original reference digest.
Check the result before marking this passed
Record the reference source, the artifact name and version, and the output and exit status. In the exercise, the original and restored file must pass and the modified file must fail.
Record the observed result and evidence location in the downloaded worksheet. Mark unresolved or untested conditions explicitly.
Recovery and cleanup
For a real mismatch, set the file aside. Confirm its exact version and architecture, obtain a fresh copy from the publisher, and repeat the check using the trusted reference.
Apply to actual work and known limits
Obtain the reference from the publisher’s official release channel. If the publisher signs its checksum manifest, follow its signature verification instructions first. A checksum match establishes that the bytes match the reference. The reference itself needs an authenticated source.