sum
sum computes a small, old-style checksum of a file and reports it along with the file's size in blocks.
sum [options] [file...]
$ sum archive.tar
12345 84 archive.tar
The output is the checksum, the block count, and the file name. With no file, sum reads standard input.
Which algorithm #
sum predates the modern hashes and offers two historical algorithms:
| Option | Algorithm |
|---|---|
-r | The BSD checksum, counted in 1 KiB blocks. This is the default. |
-s, --sysv | The System V checksum, counted in 512-byte blocks. |
When to use it #
sum exists for compatibility — for reading checksums produced by old tools, and for scripts that still expect its output. Its checksum is short and weak: it catches some accidental corruption, but it is easily fooled and gives no protection against tampering.
For anything new, do not use sum. Use a checksum command such as sha256sum, or cksum — both of which cksum can still produce, via cksum -a bsd and cksum -a sysv, if you need the legacy values.
Exit status #
| Code | Meaning |
|---|---|
0 | The checksum was computed. |
1 | A file could not be read. |