sha256sum
文件与目录
用法
sha256sum [file]打印文件的 SHA-256 指纹,用来核对下载是否完整;哈希相同只说明字节一致,并不说明来源可信。
常用选项
| 选项 | 含义 |
|---|---|
| -c | Read a list of hashes and check each file against it |
| -b | Binary mode, which matters on Windows-style line endings |
| --tag | GNU: print in the BSD format, SHA256 (file) = hash |
| --ignore-missing | GNU: with -c, skip files that are not there |
| shasum -a 256 | The same digest where sha256sum is missing, as on older macOS |
示例
sha256sum ubuntu.isoPrints the hash to compare with the download page.
sha256sum -c SHA256SUMSVerifies every file named in the checksum list.
shasum -a 256 ubuntu.isoThe portable macOS spelling.
移动、删除和查找。有些命令不会再问一遍,所以顺手加 -i 是在救自己。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. sha256sum 是做什么的?
打印文件的 SHA-256 指纹,用来核对下载是否完整;哈希相同只说明字节一致,并不说明来源可信。
Q. 怎么写?
sha256sum [file] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 5 个,完整列表在 man sha256sum。这条命令属于文件与目录。
相关命令
man 手册: man sha256sum