cksum - Calculate and display checksums and byte counts


cksum [-ciprtT] [file ... file ...]


cksum calculates and displays a checksum for each input file. A checksum is an error-checking technique used by many programs as a quick way to compare files that have been moved from one location to another to ensure that no data has been lost. It also displays the number of 8-bit bytes in each file.

If you do not specify any files on the command line, or if you specify - as the file name, cksum reads the standard input.

When _UNIX03 is YES, the cksum output has the space-separated form:
checksum bytecount filename
When _UNIX03 is unset or not YES, the cksum output has the tab-separated form:
checksum     bytecount     filename

If the file operand is not specified, the path name and its leading white space is omitted.

Read error messages are controlled by the _UNIX03 variable.
  • If cksum fails with a read error and _UNIX03 is YES, it sends a diagnostic message to standard error, and does not show a checksum for that file.
  • If _UNIX03 is unset or not YES, cksum displays the checksum up to that point and marks the output line with FSUM6199 [read error].
cksum continues processing files in either case.

All other error messages are sent to standard error.


cksum can calculate checksums in a variety of ways. The default is compatible with the POSIX standard. You can specify other algorithms with the following options. The POSIX standard does not recognize these algorithms; they are provided for compatibility with the UNIX sum command.
Uses a standard 16-bit cyclic redundancy check (CRC-16).
Uses the CCITT standard cyclic redundancy check (CRC-CCITT). Data communication network protocols often use a cyclic redundancy check to ensure proper transmission. This algorithm is more likely to produce a different sum for inputs; the only difference is byte order.
Uses the POSIX checksum algorithm. This is the default.
Enables the use of an alternate checksum algorithm that has the advantage of being sensitive to byte order.
Produces a line containing the total number of bytes of data read as well as the checksum of the concatenation of the input files.
Enables the automatic conversion of tagged files.


cksum uses the following localization environment variables:
  • LANG
  • LC_ALL

Environment variables

  • _UNIX03

For more information about the effect of _UNIX03 on the cksum command, see Shell commands changed for UNIX03.

Exit values

Successful completion.
Failure due to any of the following reasons:
  • Inability to open input file.
  • An error reading the input file.
  • Error turning off the automatic conversion of the input file.
Unknown command-line option.


POSIX.2, X/Open Portability Guide.

All the listed options are extensions of the POSIX standard.

Related information

cmp, diff, ls, sum, wc