cksum(1) User Commands cksum(1)NAMEcksum - write file checksums and sizes
SYNOPSIS
usr/bin/cksum
/usr/bin/cksum [options] [file...]
ksh93
cksum [options] [file...]
DESCRIPTION
The cksum command and ksh93 built-in command cksum lists the checksum,
and for most methods the block count, for each file argument. The stan‐
dard input is read if there are no file arguments.
The default method is cksum which calculates and writes to standard
output a cyclic redundancy check (CRC) for each input file, and also
writes to standard output the number of octets in each file.
For each file processed successfully the cksum method writes in the
following format:
"%u %d %s\n" <checksum>, <# of octets>, <path name>
Method names consist of a leading identifier and 0 or more options sep‐
arated by -.
The CRC used is based on the polynomial used for CRC error checking in
the referenced Ethernet standard.
The encoding for the CRC checksum is defined by the generating polyno‐
mial:
G(x) = x**32 + x**26 + x**23 + x**22+ x**16 + x**12 + x**11
+ x**10 + x**8 + x**7 + x**5 + x**4 + x**2 + x + 1
Mathematically, the CRC value corresponding to a given file is defined
by the following procedure:
1. The n bits to be evaluated are considered to be the coeffi‐
cients of a mod 2 polynomial M(x) of degree n−1. These n
bits are the bits from the file, with the most significant
bit being the most significant bit of the first octet of the
file and the last bit being the least significant bit of the
last octet, padded with zero bits (if necessary) to achieve
an integral number of octets, followed by one or more octets
representing the length of the file as a binary value, least
significant octet first. The smallest number of octets capa‐
ble of representing this integer is used.
2. M(x) is multiplied by x ^32 (that is, shifted left 32 bits)
and divided by G(x) using mod 2 division, producing a
remainder R(x) of degree ≤ 31.
3. The coefficients of R(x) are considered to be a 32-bit
sequence.
4. The bit sequence is complemented and the result is the CRC.
getconf PATH_RESOLVE determines how symbolic links are handled. This
can be explicitly overridden by the logical, metaphysical, and physical
options below. PATH_RESOLVE can be one of:
logical Follow all symbolic links.
metaphysical Follow command argument symbolic links, otherwise don't
follow.
physical Don't follow symbolic links.
This command conforms to IEEE Standard 1003.1-2008.
OPTIONS
The following options are supported by:
-a
--all
List the checksum for all files. Use with --total to list both
individual and total checksums and block counts.
-b
--binary
Read files in binary mode. This is the default.
-B
--scale=scale
Block count scale (bytes per block) override for methods that
include size in the output. The default is method specific.
-c--check
Each file is interpreted as the output from a previous sum. If
--header or --permissions was specified in the previous sum then
the checksum method is automatically determined, otherwise --method
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 --permissions 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 inter‐
preted as [no]name[=value] options:
method=name Checksum method to apply to subsequent lines.
permissions Subsequent lines were generated with --permissions
-h
--header
Print the checksum method as the first output line. Used with
--check and --permissions.
-l
--list
Print the checksum method as the first output line. Used with
--check and --permissions.
-p
--permissions
If --check 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 --check 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.
-R
--recursive
Recursively checksum the contents of directories.
-t--total
Recursively checksum the contents of directories.
-T--text
--warn
Read files in text mode, that is, treat \r\n as \n.
-w
--warn
Warn about invalid --check lines. This option is on by default, and
--w means --nowarn.
-x
--method|algorithm=method
Specifies the checksum method to apply. Parenthesized method
options are read-only implementation details.
att|sys5|s5|default
The system 5 release 4 checksum. This is the default for sum
when getconf UNIVERSE is att. This is the only true sum. All of
the other methods are order dependent.
ast4|32x4|tw
The ast 128 bit PRNG hash generated by concatenating 4 separate
32 bit PNRG hashes. The block count is not printed.
bsd|ucb
The BSD checksum.
crc
32 bit CRC (cyclic redundancy check).
polynomial=mask
The 32 bit crc polynomial bit mask with implicit bit 32.
The default value is 0xedb88320.
done[=number]
XOR the final crc value with number. 0xffffffff is used if
number is omitted. The option value can be omitted. The
default value is 0.
init[=number]
The initial crc value. 0xffffffff is used if number is
omitted. The option value can be omitted. The default value
is 0.
rotate
XOR each input character with the high order crc byte
(instead of the low order).
size[=number]
Include the total number of bytes in the crc. number, if
specified, is first XOR'd into the size. The option value
can be omitted. The default value is 0.
prng
32 bit PRNG (pseudo random number generator) hash.
mpy=number The 32 bit PRNG multiplier. The default value
is 0x01000193.
add=number The 32 bit PRNG addend. The default value is
0.
init]=number] The PRNG initial value. 0xffffffff is used if
number is omitted. The option value can be
omitted. The default value is 0x811c9dc5.
md4|MD4
RFC 1320 MD4 message digest. Cryptographically weak. The block
count is not printed.
(version)
md4 (solaris -lmd) 2005-07-26
md5|MD5
RFC1321 MD5 message digest. Cryptographically weak. The block
count is not printed.
(version)
md5 (solaris -lmd) 2005-07-26
sha1|SHA1|sha-1|SHA-1
RFC 3174 / FIPS 180-1 SHA-1 secure hash algorithm 1. Crypto‐
graphically weak. The block count is not printed.
(version)
sha1 (solaris -lmd) 2005-07-26
sha256|sha-256|SHA256|SHA-256
FIPS 180-2 SHA256 secure hash algorithm. The block count is not
printed.
(version)
sha256 (solaris -lmd) 2005-07-26
sha384|sha-384|SHA384|SHA-384
FIPS 180-2 SHA384 secure hash algorithm. The block count is not
printed.
(version)
sha384 (solaris -lmd) 2005-07-26
sha512|sha-512|SHA512|SHA-512
FIPS 180-2 SHA512 secure hash algorithm. The block count is not
printed.
(version)
sha512 (solaris -lmd) 2005-07-26
posix|cksum|std|standard
The posix 1003.2-1992 32 bit crc checksum. This is the default
cksum method. Shorthand for crc-0x04c11db7-rotate-done-size.
zip
The zip crc. Shorthand for crc-0xedb88320-init-done.
fddi
The FDDI crc. Shorthand for crc-0xedb88320-size=0xcc55cc55.
fnv|fnv1
The Fowler-Noll-Vo 32 bit PRNG hash with non-zero initializer
(FNV-1). Shorthand for prng-0x01000193-init=0x811c9dc5.
ast|strsum
The ast strsum(3) PRNG hash. Shorthand for
prng-0x63c63cd9-add=0x9c39c33d.
-L
--logical|follow
Follow symbolic links when traversing directories. The default is
determined by getconf PATH_RESOLVE.
-H
--metaphysical
Follow command argument symbolic links, otherwise don't follow sym‐
bolic links when traversing directories. The default is determined
by getconf PATH_RESOLVE.
-P
--physical
Don't follow symbolic links when traversing directories. The
default is determined by getconf PATH_RESOLVE.
-r
--bsd
Equivalent to --method=bsd--scale=512 for compatibility with other
sum(1) implementations.
-s
--sysv
Equivalent to ----method=sys5for compatibility with other sum(1)
implementations.
--help
Print basic help information.
--man
--html
--nroff
Print built-in manual page in either plain text, HTML or nroff for‐
mat.
--version
Print version information.
OPERANDS
The following operand is supported:
file A path name of a file to be checked. If no file operands are
specified, the standard input is used.
USAGE
The cksum command is typically used to quickly compare a suspect file
against a trusted version of the same, such as to ensure that files
transmitted over noisy media arrive intact. However, this comparison
cannot be considered cryptographically secure. The chances of a damaged
file producing the same CRC as the original are astronomically small;
deliberate deception is difficult, but probably not impossible.
Although input files to cksum can be any type, the results need not be
what would be expected on character special device files. Since this
document does not specify the block size used when doing input, check‐
sums of character special files need not process all of the data in
those files.
The algorithm is expressed in terms of a bitstream divided into octets.
If a file is transmitted between two systems and undergoes any data
transformation (such as moving 8-bit characters into 9-bit bytes or
changing Little Endian byte ordering to Big Endian), identical CRC val‐
ues cannot be expected. Implementations performing such transformations
can extend cksum to handle such situations.
See largefile(5) for the description of the behavior of cksum when
encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables
that affect the execution of cksum: LANG, LC_ALL, LC_CTYPE, LC_MES‐
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All files were processed successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Availability │SUNWcs │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │Committed │
├─────────────────────────────┼─────────────────────────────┤
│Standard │See standards(5). │
└─────────────────────────────┴─────────────────────────────┘
SEE ALSOdigest(1), ksh93(1), sum(1), bart(1M), attributes(5), environ(5),
largefile(5), standards(5)
IEEE Standard 1003.1-2008
http://www.opengroup.org
SunOS 5.11 29 Nov 2009 cksum(1)