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:

OptionAlgorithm
-rThe BSD checksum, counted in 1 KiB blocks. This is the default.
-s, --sysvThe 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 #

CodeMeaning
0The checksum was computed.
1A file could not be read.

Edit this page