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