cksum

cksum is the general checksum command. Where each of the checksum commands is fixed to one algorithm, cksum does any of them — the algorithm is an option.

cksum [options] [file...]
$ cksum installer.iso
3915528286 372736000 installer.iso
$ cksum -a sha256 --untagged installer.iso
9f86d0818884...b1a5  installer.iso

With no -a, cksum computes a CRC checksum and prints the CRC value, the file's byte count, and the name. With -a, it uses the selected algorithm. The SHA-256 example adds --untagged to request the plain hash file output; without it, SHA-256 output is tagged by default.

Choosing the algorithm #

OptionEffect
-a, --algorithm=NAMEUse the named algorithm.

NAME may be:

NameAlgorithm
crcThe default CRC.
crc32bA CRC-32 variant.
md5MD5 — as md5sum.
sha1SHA-1 — as sha1sum.
sha224, sha256, sha384, sha512The SHA-2 family — as the matching sha*sum.
sha3SHA-3.
blake2bBLAKE2b — as b2sum.
sm3The SM3 hash.
sysv, bsdThe legacy block checksums — as sum.

crc, crc32b, sha3, and sm3 are available only through cksum — there is no dedicated command for them.

Verifying #

Choose the check command to match the publisher's manifest format. Run it from the directory against which the manifest's file names were written; the manifest's own location does not set that directory. The checksum workflow covers trusted expected values, complete manifest lines and exit-status checks.

For tagged lines such as SHA256 (installer.iso) = ..., the input identifies the algorithm:

cksum --check --strict CHECKSUMS

For untagged SHA-256 lines such as hash installer.iso, supply the algorithm:

cksum --algorithm=sha256 --check --strict SHA256SUMS

The dedicated sha256sum --check --strict SHA256SUMS command already selects SHA-256. With cksum, an explicitly selected algorithm must agree with any tagged input. Do not add --tag, --binary or --text to a check command: those output-mode options are rejected during verification.

You cannot combine --check with --algorithm=crc, crc32b, bsd or sysv. The default CRC output is not a checkable checksum manifest. Use normal newline-delimited checksum output for manifests; --zero output is not read as NUL-delimited check input.

OptionEffect
-c, --checkRead checksums and verify the files against them.
--ignore-missingSkip unavailable listed files when intentionally checking a subset; see the caveat below.
--quietPrint nothing for files that pass.
--statusSuppress comparison results and summary warnings; check the exit status. File-access or argument errors may still print diagnostics.
-w, --warnWarn about malformed checksum lines.
--strictFail on a malformed checksum line.

Without --strict, malformed lines can be skipped while a check still succeeds. A checksum input with no properly formatted lines fails in either mode. Use --ignore-missing only for an intentional subset: the current implementation skips file-open failures beyond missing files, so success does not establish that the whole set was available. It still fails if no file in a checksum input verifies successfully.

Output format #

OptionEffect
--tagProduce a tagged ALGORITHM (file) = hash line. The default for most algorithms.
--untaggedProduce a plain hash file line.
--rawOutput the raw binary digest, with nothing else.
--base64Print the digest in base64 rather than hexadecimal.
-l, --length=BITSFor an algorithm that supports it, produce a shorter digest.
-z, --zeroEnd each output line with a NUL character.

Exit status #

CodeMeaning
0Success under the selected options.
1Verification failed, a file could not be accessed or read, or input/options were invalid. Malformed checksum lines cause failure with --strict, or when no properly formatted lines exist.

These verification rules are checked against current command handling and manifest validation, not tested on an installed Peios release. Treat any nonzero status as failure.

Edit this page