HOME

TheInfoList



OR:

is a legacy utility available on some
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
and Unix-like
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s. This utility outputs a 16-bit
checksum A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify data ...
of each argument
file File or filing may refer to: Mechanical tools and processes * File (tool), a tool used to ''remove'' fine amounts of material from a workpiece **Filing (metalworking), a material removal process in manufacturing ** Nail file, a tool used to gent ...
, as well as the number of blocks they take on disk. — manual pages from
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
coreutils The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems. In September 2002, the ''GNU coreutils'' were ...
Two different checksum algorithms are in use. POSIX abandoned sum in favor of
cksum cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the f ...
.


Overview

The program is generally only useful for historical interest. It is not part of POSIX. Two algorithms are typically available: a BSD checksum and a SYSV checksum. Both are weaker than the already weak 32-bit CRC used by
cksum cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the f ...
. The
default Default may refer to: Law * Default (law), the failure to do something required by law ** Default (finance), failure to satisfy the terms of a loan obligation or failure to pay back a loan ** Default judgment, a binding judgment in favor of ei ...
algorithm on FreeBSD and GNU implementations is the BSD checksum. Switching between the two algorithms is done via command line options. The two commonly used algorithms are as follows. The BSD sum, -r in GNU sum and -o1 in FreeBSD cksum: * Initialize checksum to 0 * For each byte of the input stream ** Perform 16-bit bitwise right rotation by 1 bit on the checksum ** Add the byte to the checksum, and apply modulo 2 ^ 16 to the result, thereby keeping it within 16 bits * The result is a 16-bit checksum The above algorithm appeared in
Seventh Edition Unix Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercial ...
. The System V sum, -s in GNU sum and -o2 in FreeBSD cksum: * checksum0 = sum of all bytes of the input stream modulo 2 ^ 32 * checksum1 = checksum0 modulo 2 ^ 16 + checksum0 / 2 ^ 16 * checksum = checksum1 modulo 2 ^16 + checksum1 / 2 ^ 16 * The result is a 16-bit checksum calculated from the initial 32-bit plain byte sum


Syntax

The utility is invoked from the
command line A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
according to the following syntax: sum PTION..
ILE Ile may refer to: * iLe, a Puerto Rican singer * Ile District (disambiguation), multiple places * Ilé-Ifẹ̀, an ancient Yoruba city in south-western Nigeria * Interlingue (ISO 639:ile), a planned language * Isoleucine, an amino acid * Another ...
.. with the possible option parameters being: * ** use BSD checksum algorithm, use 1K blocks (defeats ) * , ** use SYSV checksum algorithm, use 512 bytes blocks * ** display the help screen and exit * ** output version information and exit When no file parameter is given, or when FILE is , the
standard input In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdi ...
is used as input file. Example of use: $ echo Hello > testfile $ sum testfile 36978 1 Example of -s use in GNU sum: $ echo Hello > testfile $ sum -s testfile 510 1 testfile Example of using standard input, -r and printf to avoid newline: $ printf Hello , sum -r 08401 1


See also

*
GNU Core Utilities The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems. In September 2002, the ''GNU coreutils'' were ...
*
UnxUtils UnxUtils is a collection of ports of common GNU Unix-like utilities to native Win32, with executables only depending on the Microsoft C- runtime msvcrt.dll. The collection was last updated externally on April 15, 2003, by Karl M. Syring. The ...
port to native Win32


References


External links


sum
in The Single UNIX ® Specification, Version 2, 1997, opengroup.org – does not specify checksum algorithm

in The Open Group Base Specifications Issue 7, 2018 edition, opengroup.org – indicates sum as removed * * – manual pages from
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
coreutils The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems. In September 2002, the ''GNU coreutils'' were ...
* – states the sum algorithms in options -o1 and -o2 to cksum * *
The Unix Tree
tuhs.org – the source code of old versions of Unix {{Core Utilities commands Linux package management-related software Unix package management-related software Linux security software Unix security-related software