Session and utilities
The sha256sum command
Computes the SHA-256 hash of files to verify downloads and integrity.
Most useful options
-c, --checkReads a checksum file and verifies each file, printing OK or FAILED--ignore-missingWith -c, skips without reporting the listed files that do not exist--quietWith -c, does not print OK for each correct file, only the failures--statusWith -c, prints nothing: only the exit code, 0 if everything matches--strictWith -c, exits with an error if any line of the list is badly formatted-b, --binaryReads in binary mode. On GNU systems it does not change the result compared to text mode-z, --zeroEnds each line with a null byte instead of a newlineCopy-ready examples
$ sha256sum /etc/passwdSHA-256 hash of a system file.$ sha256sum /etc/passwd /etc/groupseveral hashes at once, one line per file.$ printf 'hola\n' > hola.txt && sha256sum hola.txteach line is the sum, two spaces and the name.Example output
133ee989293f92736301280c6f14c89d521200c17dcdcecca30cd20705332d44 hola.txt
$ sha256sum hola.txt > SHA256SUMS && sha256sum -c SHA256SUMSsaves the sum and checks it later. OK confirms the file is unchanged.Example output
hola.txt: OK
You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| sha256sum: noexiste.txt: No such file or directory | The file does not exist or the name is misspelled. | Check the path with ls before computing the hash. |
| sha256sum: basura.txt: no properly formatted SHA256 checksum lines found | You passed a file that is not a checksum list, for example the original or a page downloaded by mistake. | Pass the file that holds the sums. Each line must have a sum, two spaces and a name. |
| sha256sum: WARNING: 1 computed checksum did NOT match | The file has changed since the sum was generated: it is damaged, edited or another version. The line shows as FAILED. | Download it again from the official source and compare again. |
Typical mistakes
- Store the hash exactly: if a single byte changes, verification fails.
- A sum only proves the file matches the list. If the list arrives modified together with the file, the check passes anyway.
- With -c, the names in the list are looked up from the current folder: run it in the folder where the list was created, or the paths will not match.
Differences from similar commands
FAQ
What do OK and FAILED mean when verifying?
OK: the file matches the sum in the list. FAILED: it does not match, because it changed, or it could not be opened if 'open or read' appears.
Can I check several downloads with one checksum file?
Yes: put one line per file in the same file and verify with sha256sum -c. With --ignore-missing, the ones you do not have are skipped.
What does 'no properly formatted SHA256 checksum lines found' mean?
That the file you passed to -c has no lines in checksum format. It usually happens when you name the original instead of the list.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course