1cksum(1) User Commands cksum(1)
2
3
4
6 cksum - write file checksums and sizes
7
9 cksum [file]...
10
11
13 The cksum command calculates and writes to standard output a cyclic
14 redundancy check (CRC) for each input file, and also writes to standard
15 output the number of octets in each file.
16
17
18 For each file processed successfully, cksum will write in the following
19 format:
20
21
22 "%u %d %s\n" <checksum>, <# of octets>, <path name>
23
24
25 If no file operand was specified, the path name and its leading space
26 will be omitted.
27
28
29 The CRC used is based on the polynomial used for CRC error checking in
30 the referenced Ethernet standard.
31
32
33 The encoding for the CRC checksum is defined by the generating polyno‐
34 mial:
35
36
37 G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 +
38 x^7 + x^5 + x^4 + x^2 + x + 1
39
40
41 Mathematically, the CRC value corresponding to a given file is defined
42 by the following procedure:
43
44 1. The n bits to be evaluated are considered to be the coeffi‐
45 cients of a mod 2 polynomial M(x) of degree n−1. These n
46 bits are the bits from the file, with the most significant
47 bit being the most significant bit of the first octet of the
48 file and the last bit being the least significant bit of the
49 last octet, padded with zero bits (if necessary) to achieve
50 an integral number of octets, followed by one or more octets
51 representing the length of the file as a binary value, least
52 significant octet first. The smallest number of octets capa‐
53 ble of representing this integer is used.
54
55 2. M(x) is multiplied by x ^32 (that is, shifted left 32 bits)
56 and divided by G(x) using mod 2 division, producing a
57 remainder R(x) of degree ≤ 31.
58
59 3. The coefficients of R(x) are considered to be a 32-bit
60 sequence.
61
62 4. The bit sequence is complemented and the result is the CRC.
63
65 The following operand is supported:
66
67 file A path name of a file to be checked. If no file operands are
68 specified, the standard input is used.
69
70
72 The cksum command is typically used to quickly compare a suspect file
73 against a trusted version of the same, such as to ensure that files
74 transmitted over noisy media arrive intact. However, this comparison
75 cannot be considered cryptographically secure. The chances of a damaged
76 file producing the same CRC as the original are astronomically small;
77 deliberate deception is difficult, but probably not impossible.
78
79
80 Although input files to cksum can be any type, the results need not be
81 what would be expected on character special device files. Since this
82 document does not specify the block size used when doing input, check‐
83 sums of character special files need not process all of the data in
84 those files.
85
86
87 The algorithm is expressed in terms of a bitstream divided into octets.
88 If a file is transmitted between two systems and undergoes any data
89 transformation (such as moving 8-bit characters into 9-bit bytes or
90 changing "Little Endian" byte ordering to "Big Endian"), identical CRC
91 values cannot be expected. Implementations performing such transforma‐
92 tions may extend cksum to handle such situations.
93
94
95 See largefile(5) for the description of the behavior of cksum when
96 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
97
99 See environ(5) for descriptions of the following environment variables
100 that affect the execution of cksum: LANG, LC_ALL, LC_CTYPE, LC_MES‐
101 SAGES, and NLSPATH.
102
104 The following exit values are returned:
105
106 0 All files were processed successfully.
107
108
109 >0 An error occurred.
110
111
113 See attributes(5) for descriptions of the following attributes:
114
115
116
117
118 ┌─────────────────────────────┬─────────────────────────────┐
119 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
120 ├─────────────────────────────┼─────────────────────────────┤
121 │Availability │SUNWcsu │
122 ├─────────────────────────────┼─────────────────────────────┤
123 │Interface Stability │Standard │
124 └─────────────────────────────┴─────────────────────────────┘
125
127 digest(1), sum(1), bart(1M), attributes(5), environ(5), largefile(5),
128 standards(5)
129
130
131
132SunOS 5.11 1 Feb 1995 cksum(1)