首页·终端命令

sha256sum

文件与目录

用法

sha256sum [file]

打印文件的 SHA-256 指纹,用来核对下载是否完整;哈希相同只说明字节一致,并不说明来源可信。

常用选项

选项含义
-cRead a list of hashes and check each file against it
-bBinary mode, which matters on Windows-style line endings
--tagGNU: print in the BSD format, SHA256 (file) = hash
--ignore-missingGNU: with -c, skip files that are not there
shasum -a 256The same digest where sha256sum is missing, as on older macOS

示例

sha256sum ubuntu.iso

Prints the hash to compare with the download page.

sha256sum -c SHA256SUMS

Verifies every file named in the checksum list.

shasum -a 256 ubuntu.iso

The portable macOS spelling.

移动、删除和查找。有些命令不会再问一遍,所以顺手加 -i 是在救自己。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. sha256sum 是做什么的?

打印文件的 SHA-256 指纹,用来核对下载是否完整;哈希相同只说明字节一致,并不说明来源可信。

Q. 怎么写?

sha256sum [file] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 5 个,完整列表在 man sha256sum。这条命令属于文件与目录。

相关命令

man 手册: man sha256sum