Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, February 10, 2021
 
 

sum(1)

Name

sum - print checksum and block count for a file

Synopsis

/usr/bin/sum [-r] [file...]

Description

The sum lists the checksum for each of its file arguments. The standard input is read if there are no file arguments.

Options

The following option is supported:

–r

Use an alternate (machine-dependent) algorithm in computing the checksum.

Operands

The following operands are supported:

file

A path name of a file. If no files are named, the standard input is used.

Environment Variables

See environ(7) for descriptions of the following environment variables that affect the execution of sum: LC_CTYPE, LC_MESSAGES, and NLSPATH.

Exit Status

The following exit values are returned.

0

Successful completion.

> 0

An error occurred.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
CSI
Enabled

See Also

cksum(1), digest(1), getconf(1), wc(1), libmd(3LIB), attributes(7), environ(7)

Diagnostics

Read error is indistinguishable from end of file on most devices. Check the block count.

Notes

Portable applications should use cksum(1). The default algorithm for this command is defined in the POSIX standard and is identical across platforms.

The sum 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. When compatibility with existing sum usage or values is not required, the digest(1) command is recommended instead, as it provides more modern and secure algorithms.

In previous releases of Solaris, there was a /usr/ucb/sum that returned a different checksum than the sum command described here due to different blocksizes and algorithms used. The command sum uses 512 byte block sizes while /usr/ucb/sum used 1024 byte block sizes.