Go to main content

手册页部分 1:用户命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

sum(1)

名称

sum - 打印文件的校验和和块计数

用法概要

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

描述

sum 会列出每个文件参数的校验和。如果没有文件参数,则读取标准输入。

选项

支持以下选项:

–r

在计算校验和时使用备用算法(取决于计算机)。

操作数

支持下列操作数:

file

文件的路径名。如果未命名任何文件,则使用标准输入。

环境变量

有关影响 sum 执行执行的以下环境变量的说明,请参见 environ(7):LC_CTYPE、LC_MESSAGES 和 NLSPATH。

退出状态

将返回以下退出值。

0

成功完成。

> 0

出现错误。

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
system/core-os
CSI
Enabled(已启用)

另请参见

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

诊断

不能从大多数设备上的文件结尾中区分读取错误。请检查块计数。

附注

可移植应用程序应使用 cksum(1)。此命令的缺省算法定义在 POSIX 标准中且在所有平台中都相同。

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.但是,不能将这种比较视为加密形式的安全保护。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.