Displays the checksum and byte count of a file.
cksum [ File ... ]
The cksum command reads the files specified by the File parameter and calculates a 32-bit checksum Cyclic Redundancy Check (CRC) and the byte count for each file. If no files are specified, the cksum command reads standard input. The checksum, number of bytes, and file name are written to standard output. If standard input is used, the path name and leading space are omitted.
The cksum command can be used to compare a suspect file copied or communicated over noisy transmission lines against an exact copy of a trusted file. The comparison made by the cksum command may not be cryptographically secure. However, it is unlikely that an accidentally damaged file will produce the same checksum as the original file.
The cksum command uses a different algorithm to calculate the 32-bit checksum CRC than the sum command. The cksum command uses a CRC algorithm based on the Ethernet standard frame check.
Note: The cksum command is POSIX 1003.2 compliant and the checksum produced is guaranteed to be calculated the same on all POSIX 1003.2 compliant systems.
The following generating polynomial defines CRC checksum encoding:
G(x) = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1
The following procedure mathematically defines the CRC value corresponding to a given file:
This command returns the following exit values:
Item | Description |
---|---|
0 | All files were processed successfully. |
>0 | An error occurred. |
To display the checksum and the size, in bytes, of file1 and file2, enter:
cksum file1 file2
If the checksum of the file1 file is 3995432187 and contains 1390 bytes, and the checksum of the file2 file is 3266927833 and contains 20912 bytes, the cksum command displays:
3995432187 1390 file1
3266927833 20912 file2
Item | Description |
---|---|
/usr/bin/cksum | Contains the cksum command. |