1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
|
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group. In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
.\"
.TH SUM 1 "May 23, 2021"
.SH NAME
sum \- print checksum and block count for a file
.SH SYNOPSIS
.nf
\fB/usr/bin/sum\fR [-abBchHlLpPrRstTw] [-x method] [\fIfile\fR...]
.fi
.SS "ksh93"
.nf
sum [-abBchHlLpPrRstTw] [-x method] [\fIfile\fR...]
.fi
.SH DESCRIPTION
The \fBsum\fR utility and ksh93 built-in command list the checksum, and for
most methods the block count, for each file argument. The standard input is
read if there are no file arguments.
.sp
.LP
The \fBgetconf\fR(1) \fBUNIVERSE\fR determines the default sum method: att for
the att universe, bsd otherwise. The default for the other commands is the
command name itself. The att method is a true sum, all others are order
dependent.
.sp
.LP
Method names consist of a leading identifier and 0 or more options separated by
-.
.sp
.LP
\fBgetconf\fR \fBPATH_RESOLVE\fR determines how symbolic links are handled.
This can be explicitly overridden by the \fB--logical\fR, \fB--metaphysical\fR,
and \fB--physical\fR options below. \fBPATH_RESOLVE\fR can be one of:
.sp
.ne 2
.na
\fB\fB--logical\fR\fR
.ad
.RS 18n
Follow all symbolic links.
.RE
.sp
.ne 2
.na
\fB\fB--metaphysical\fR\fR
.ad
.RS 18n
Follow command argument symbolic links, otherwise do not follow.
.RE
.sp
.ne 2
.na
\fB\fB--physical\fR\fR
.ad
.RS 18n
Do not follow symbolic links.
.RE
.SH OPTIONS
The following options are supported for \fB/usr/bin/sum\fR:
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.br
.na
\fB\fB--all\fR\fR
.ad
.sp .6
.RS 4n
List the checksum for all files. Use with \fB--total\fR to list both individual
and total checksums and block counts.
.RE
.sp
.ne 2
.na
\fB\fB-b\fR\fR
.ad
.br
.na
\fB\fB--binary\fR\fR
.ad
.sp .6
.RS 4n
Read files in binary mode. This is the default.
.RE
.sp
.ne 2
.na
\fB\fB-B\fR\fR
.ad
.br
.na
\fB\fB--scale=scale\fR\fR
.ad
.sp .6
.RS 4n
Block count scale (bytes per block) override for methods that include size in
the output. The default is method-specific.
.RE
.sp
.ne 2
.na
\fB\fB-c\fR\fR
.ad
.br
.na
\fB\fB--check\fR\fR
.ad
.sp .6
.RS 4n
Each file is interpreted as the output from a previous sum. If \fB--header\fR
or \fB--permissions\fR was specified in the previous sum then the checksum
method is automatically determined, otherwise \fB--method\fR must be specified.
The listed checksum is compared with the current value and a warning is issued
for each file that does not match. If file was generated by
\fB--permissions\fR, then the file mode, user and group are also checked. Empty
lines, lines starting with #<space>, or the line # are ignored. Lines
containing no blanks are interpreted as [no]name[=\fIvalue\fR] options:
.sp
.ne 2
.na
\fB\fBmethod=name\fR\fR
.ad
.sp .6
.RS 4n
Checksum method to apply to subsequent lines.
.RE
.sp
.ne 2
.na
\fB\fBpermissions\fR\fR
.ad
.sp .6
.RS 4n
Subsequent lines were generated with \fB--permissions\fR.
.RE
.RE
.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.br
.na
\fB\fB--header\fR\fR
.ad
.sp .6
.RS 4n
Print the checksum method as the first output line. Used with \fB--check\fR and
\fB--permissions\fR.
.RE
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.br
.na
\fB\fB--list\fR\fR
.ad
.sp .6
.RS 4n
Each file is interpreted as a list of files, one per line, that is checksummed.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.br
.na
\fB\fB--permissions\fR\fR
.ad
.sp .6
.RS 4n
If \fB--check\fR is not specified then list the file mode, user and group
between the checksum and path. User and group matching the caller are output as
-. If \fB--check\fR is specified then the mode, user and group for each path in
file are updated if necessary to match those in file. A warning is printed on
the standard error for each changed file.
.RE
.sp
.ne 2
.na
\fB\fB-R\fR\fR
.ad
.br
.na
\fB\fB--recursive\fR\fR
.ad
.sp .6
.RS 4n
Recursively checksum the contents of directories.
.RE
.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.br
.na
\fB\fB--total\fR\fR
.ad
.sp .6
.RS 4n
List only the total checksum and block count of all files. \fB--all\fR
\fB--total\fR lists each checksum and the total. The total checksum and block
count may be different from the checksum and block count of the catenation of
all files due to partial blocks that may occur when the files are treated
separately.
.RE
.sp
.ne 2
.na
\fB\fB-T\fR\fR
.ad
.br
.na
\fB\fB--text\fR\fR
.ad
.sp .6
.RS 4n
Read files in text mode (for example, treat \er\en as \en).
.RE
.sp
.ne 2
.na
\fB\fB-w\fR\fR
.ad
.br
.na
\fB\fB--warn\fR\fR
.ad
.sp .6
.RS 4n
Warn about invalid \fB--check\fR lines. On by default; \fB-w\fR means
\fB--nowarn\fR.
.RE
.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.br
.na
\fB\fB--method|algorithm=method\fR\fR
.ad
.sp .6
.RS 4n
Specifies the checksum method to apply. Parenthesized method options are
readonly implementation details.
.sp
.ne 2
.na
\fB\fBatt\fR|\fBsys5\fR|\fBs5\fR|\fBdefault\fR\fR
.ad
.sp .6
.RS 4n
The system 5 release 4 checksum. This is the default for sum when \fBgetconf\fR
\fBUNIVERSE\fR is \fBatt\fR. This is the only true sum; all of the other
methods are order dependent.
.RE
.sp
.ne 2
.na
\fB\fBast4\fR|\fB32x4\fR|\fBtw\fR\fR
.ad
.sp .6
.RS 4n
The \fBast\fR 128 bit \fBPRNG\fR hash generated by catenating 4 separate 32 bit
\fBPNRG\fR hashes. The block count is not printed.
.RE
.sp
.ne 2
.na
\fB\fBbsd\fR|\fBucb\fR\fR
.ad
.sp .6
.RS 4n
The BSD checksum.
.RE
.sp
.ne 2
.na
\fB\fBcrc\fR\fR
.ad
.sp .6
.RS 4n
32 bit CRC (cyclic redundancy check).
.sp
.ne 2
.na
\fB\fBpolynomial\fR=\fImask\fR\fR
.ad
.sp .6
.RS 4n
The 32 bit \fBcrc\fR polynomial bitmask with implicit bit 32. The default value
is 0xedb88320.
.RE
.sp
.ne 2
.na
\fB\fBdone\fR[=\fInumber\fR]\fR
.ad
.sp .6
.RS 4n
XOR the final \fBcrc\fR value with number. 0xffffffff is used if number is
omitted. The option value may be omitted. The default value is 0.
.RE
.sp
.ne 2
.na
\fB\fBinit\fR[=\fInumber\fR]\fR
.ad
.sp .6
.RS 4n
The initial \fBcrc\fR value. 0xffffffff is used if number is omitted. The
option value may be omitted. The default value is 0.
.RE
.sp
.ne 2
.na
\fB\fBrotate\fR\fR
.ad
.sp .6
.RS 4n
XOR each input character with the high order \fBcrc\fR byte (instead of the low
order).
.RE
.sp
.ne 2
.na
\fB\fBsize\fR[=\fInumber\fR]\fR
.ad
.sp .6
.RS 4n
Include the total number of bytes in the crc. number, if specified, is first
XOR'd into the size. The option value may be omitted. The default value is 0.
.RE
.RE
.sp
.ne 2
.na
\fB\fBprng\fR\fR
.ad
.sp .6
.RS 4n
32 bit \fBPRNG\fR (pseudo random number generator) hash.
.sp
.ne 2
.na
\fB\fBmpy\fR=\fInumber\fR\fR
.ad
.RS 17n
The 32 bit \fBPRNG\fR multiplier. The default value is 0x01000193.
.RE
.sp
.ne 2
.na
\fB\fBadd\fR=\fInumber\fR\fR
.ad
.RS 17n
The 32 bit \fBPRNG\fR addend. The default value is 0.
.RE
.sp
.ne 2
.na
\fB\fBinit\fR[=\fInumber\fR]\fR
.ad
.RS 17n
The \fBPRNG\fR initial value. 0xffffffff is used if number is omitted. The
option value may be omitted. The default value is 0x811c9dc5.
.RE
.RE
.sp
.ne 2
.na
\fB\fBmd4\fR|\fBMD4\fR\fR
.ad
.sp .6
.RS 4n
\fBRFC1320\fR \fBMD4\fR message digest. Cryptographically weak. The block count
is not printed. (version) \fBmd4\fR (\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBmd5\fR|\fBMD5\fR\fR
.ad
.sp .6
.RS 4n
\fBRFC1321\fR \fBMD5\fR message digest. Cryptographically weak. The block count
is not printed. (version) \fBmd5\fR (\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBsha1\fR|\fBSHA1\fR|\fBsha-1\fR|\fBSHA-1\fR\fR
.ad
.sp .6
.RS 4n
\fBRFC3174\fR / \fBFIPS 180-1\fR \fBSHA-1\fR secure hash algorithm 1.
Cryptographically weak. The block count is not printed. (version) \fBsha1\fR
(\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBsha256\fR|\fBsha-256\fR|\fBSHA256\fR|\fBSHA-256\fR\fR
.ad
.sp .6
.RS 4n
\fBFIPS 180-2\fR \fBSHA256\fR secure hash algorithm. The block count is not
printed. (version) \fBsha256\fR (\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBsha384\fR|\fBsha-384\fR|\fBSHA384\fR|\fBSHA-384\fR\fR
.ad
.sp .6
.RS 4n
\fBFIPS 180-2\fR \fBSHA384\fR secure hash algorithm. The block count is not
printed. (version) \fBsha384\fR (\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBsha512\fR|\fBsha-512\fR|\fBSHA512\fR|\fBSHA-512\fR\fR
.ad
.sp .6
.RS 4n
\fBFIPS 180-2\fR \fBSHA512\fR secure hash algorithm. The block count is not
printed. (version) \fBsha512\fR (\fBsolaris\fR \fB-lmd\fR) 2005-07-26
.RE
.sp
.ne 2
.na
\fB\fBposix\fR|\fBcksum\fR|\fBstd\fR|\fBstandard\fR\fR
.ad
.sp .6
.RS 4n
The \fBposix 1003.2-1992\fR 32 bit \fBcrc\fR checksum. This is the default
\fBcksum\fR(1) method. Shorthand for \fBcrc-0x04c11db7-rotate-done-size\fR.
.RE
.sp
.ne 2
.na
\fB\fBzip\fR\fR
.ad
.sp .6
.RS 4n
The \fBzip\fR(1) \fBcrc\fR. Shorthand for \fBcrc-0xedb88320-init-done\fR.
.RE
.sp
.ne 2
.na
\fB\fBfddi\fR\fR
.ad
.sp .6
.RS 4n
The \fBFDDI\fR \fBcrc\fR. Shorthand for
\fBcrc-0xedb88320-size\fR=\fB0xcc55cc55\fR.
.RE
.sp
.ne 2
.na
\fB\fBfnv\fR|\fBfnv1\fR\fR
.ad
.sp .6
.RS 4n
The \fBFowler-Noll-Vo\fR 32 bit \fBPRNG\fR hash with non-zero initializer
(\fBFNV-1\fR). Shorthand for \fBprng-0x01000193-init\fR=\fB0x811c9dc5\fR.
.RE
.sp
.ne 2
.na
\fB\fBast\fR|\fBstrsum\fR\fR
.ad
.sp .6
.RS 4n
The \fBast\fR \fBstrsum\fR \fBPRNG\fR hash. Shorthand for
\fBprng-0x63c63cd9-add\fR=\fB0x9c39c33d\fR.
.RE
.RE
.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.br
.na
\fB\fB--logical\fR|\fBfollow\fR\fR
.ad
.sp .6
.RS 4n
Follow symbolic links when traversing directories. The default is determined by
\fBgetconf\fR \fBPATH_RESOLVE\fR.
.RE
.sp
.ne 2
.na
\fB\fB-H\fR\fR
.ad
.br
.na
\fB\fB--metaphysical\fR\fR
.ad
.sp .6
.RS 4n
Follow command argument symbolic links, otherwise do not follow symbolic links
when traversing directories. The default is determined by \fBgetconf\fR
\fBPATH_RESOLVE\fR.
.RE
.sp
.ne 2
.na
\fB\fB-P\fR\fR
.ad
.br
.na
\fB\fB--physical\fR\fR
.ad
.sp .6
.RS 4n
Do not follow symbolic links when traversing directories. The default is
determined by \fBgetconf\fR \fBPATH_RESOLVE\fR.
.RE
.sp
.ne 2
.na
\fB\fB-r\fR\fR
.ad
.br
.na
\fB\fB--bsd\fR\fR
.ad
.sp .6
.RS 4n
Equivalent to \fB--method=bsd\fR \fB--scale=512\fR for compatibility with other
sum implementations.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.br
.na
\fB\fB--sysv\fR\fR
.ad
.sp .6
.RS 4n
Equivalent to \fB--method=sys5\fR for compatibility with other sum
implementations.
.RE
.sp
.ne 2
.na
\fB\fB-S\fR\fR
.ad
.br
.na
\fB\fB--silent\fR|\fBstatus\fR\fR
.ad
.sp .6
.RS 4n
No output for \fB--check\fR; 0 exit status means all sums matched, non-0 means
at least one sum failed to match. Ignored for \fB--permissions\fR.
.RE
.SH OPERANDS
The following operands are supported:
.sp
.ne 2
.na
\fB\fIfile\fR\fR
.ad
.RS 8n
A path name of a file. If no files are named, the standard input is used.
.RE
.SH USAGE
See \fBlargefile\fR(7) for the description of the behavior of \fBsum\fR when
encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
.SH ENVIRONMENT VARIABLES
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBsum\fR: \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and
\fBNLSPATH\fR.
.SH EXIT STATUS
The following exit values are returned.
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
CSI Enabled
.TE
.SH SEE ALSO
.BR cksum (1),
.BR digest (1),
.BR getconf (1),
.BR ksh93 (1),
.BR wc (1),
.BR zip (1),
.BR sum (1B),
.BR libmd (3LIB),
.BR attributes (7),
.BR environ (7),
.BR largefile (7)
.SH DIAGNOSTICS
\fBRead error\fR is indistinguishable from end of file on most devices. Check
the block count.
.SH NOTES
Portable applications should use \fBcksum\fR(1). The default algorithm for this
command is defined in the POSIX standard and is identical across platforms.
.sp
.LP
\fBsum\fR and \fB/usr/ucb/sum\fR (see \fBsum\fR(1B)) return different checksums.
|