linux中校验文件完整性(md5,sha1)
经常在Linux下下载软件的人,一定会有一个良好的习惯:校验文件的hash,以确定文件的完整性甚至是安全性。我配置环境的时候也恰好用到了,笔者的是一个lubuntu的机子。这里我大致做个记录。(不了解hash的请自行查阅相关资料)
MD5校验:
magic@luna:~/lnmp$ md5sum lnmp1.3-full.tar.gz
a5aa55cd177cd9b9176ad697c12e45c0 lnmp1.3-full.tar.gz
或者我们可以保存到一个文件中:
magic@luna:~/lnmp$ md5sum lnmp1.3-full.tar.gz > md5-hash.txt
然后:
magic@luna:~/lnmp$ cat md5-hash.txt
a5aa55cd177cd9b9176ad697c12e45c0 lnmp1.3-full.tar.gz
还可以根据已经得到的hash来确认文件:
magic@luna:~/lnmp$ md5sum -c md5-hash.txt
lnmp1.3-full.tar.gz: 确定
magic@luna:~/lnmp$
SHA1:
这个类似于MD5校验方法:
magic@luna:~/lnmp$ sha1sum lnmp1.3-full.tar.gz
ee7ec6e8be0b3b5a481df903427261236f9bb057 lnmp1.3-full.tar.gz
或者保存到文件中再去查看:
magic@luna:~/lnmp$ sha1sum lnmp1.3-full.tar.gz > sha1-hash.txt
magic@luna:~/lnmp$ cat sha1-hash.txt
ee7ec6e8be0b3b5a481df903427261236f9bb057 lnmp1.3-full.tar.gz
已知hash情况下的校验(通常这个情况还挺多):
magic@luna:~/lnmp$ sha1sum -c sha1-hash.txt
lnmp1.3-full.tar.gz: 确定
magic@luna:~/lnmp$
注意事项:在已知hash数值情况下对文件进行校验的时候要注意,一定要让系统能够找到要校验的文件。否则就没法进行校验了。具体的使用说明,可以通过md5(sha1)sum --help来查看:
magic@luna:~/lnmp$ sha1sum --help
Usage: sha1sum [OPTION]... [FILE]...
Print or check SHA1 (160-bit) checksums. 如果没有指定文件,或者文件为"-",则从标准输入读取。 -b, --binary read in binary mode
-c, --check 从文件中读取SHA1 的校验值并予以检查
--tag create a BSD-style checksum
-t, --text 以纯文本模式读取(默认) The following five options are useful only when verifying checksums:
--ignore-missing don't fail or report status for missing files
--quiet don't print OK for each successfully verified file
--status don't output anything, status code shows success
--strict exit non-zero for improperly formatted checksum lines
-w, --warn warn about improperly formatted checksum lines --help 显示此帮助信息并退出
--version 显示版本信息并退出 The sums are computed as described in FIPS-180-1. When checking, the input
should be a former output of this program. The default mode is to print a
line with checksum, a space, a character indicating input mode ('*' for binary,
' ' for text or where binary is insignificant), and name for each FILE. GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告sha1sum 的翻译错误
Full documentation at: <http://www.gnu.org/software/coreutils/sha1sum>
or available locally via: info '(coreutils) sha1sum invocation'
ps:转载请注明文章出处。
linux中校验文件完整性(md5,sha1)的更多相关文章
- Linux md5sum校验文件完整性
使用场景: 远程备份大文件,防止网络异常断开,文件备份不完整,使用md5校验其完整性. 1. 获取文件md5值 [root@kvm-123 gitlab]# md5sum 1564248991_20 ...
- mac上校验文件的 md5 sha-1
文件校验 mac md5 sha-1html, body {overflow-x: initial !important;}.CodeMirror { height: auto; } .CodeMir ...
- Linux下查询文件的md5,sha1值
验证下载下来的文件包是不是一致 ··· 验证md5值 #md5sum filename 验证shal值 #sha1sum filename ···
- Linux下校验下载文件的完整性(MD5,SHA1,PGP)
查看: Linux下校验下载文件的完整性(MD5,SHA1,PGP) http://blog.useasp.net/archive/2014/03/29/use-md5-sha1-or-pgp-to- ...
- Shell 对整个文件夹中的文件进行MD5校验 [转]
查看本地文件的 MD5 命令:md5sum FileName查看home目录下所有文件的 MD5 码:cd ~find /home -type f -print0 | xargs -0 md5sum ...
- Hash校验工具、MD5 SHA1 SHA256命令行工具
MyHash 检验工具http://www.zdfans.com/html/4346.html HashMyFiles Hash校验工具http://www.nirsoft.net/utils/has ...
- 【转】linux中inittab文件详解
原文网址:http://www.2cto.com/os/201108/98426.html linux中inittab文件详解 init的进程号是1(ps -aux | less),从这一点就能看出, ...
- Linux中检索文件
1 , Use locate command It is a fast way to find the files location, but if a file just created ,it w ...
- Linux中查看文件编码
在Linux中查看文件编码可以通过以下几种方式:1.在Vim中可以直接查看文件编码:set fileencoding即可显示文件编码格式.如果你只是想查看其它编码格式的文件或者想解决用Vim查看文件乱 ...
随机推荐
- sql2008 安装提示重启失败
[转] https://www.cnblogs.com/chenshaogang/p/4313022.html
- a Concise Sparse Matrix package
简明稀疏矩阵包 https://github.com/kulhanek/csparse https://github.com/kulhanek/csparse
- Greeplum 系列(三) 基本用法
Greeplum 系列(三) 基本用法 <PostgreSQL 教程>:https://www.yiibai.com/postgresql 一.Greeplum 登陆与创建 1.1 登陆 ...
- ceph卸载
1.正常卸载 ceph-deploy purge ceph01 ceph-deploy purgedata ceph01 rm -rf /var/lib/ceph rm -rf /etc/ceph r ...
- vscode填坑之旅: vscode设置中文,设置中文不成功问题
刚安装好的vscode界面显示中文,如何设置中文呢? 在locale.json界面设置”locale":"zh-cn"也未能实现界面为中文,在网上找了参考了,以下教程真实 ...
- Unity NetWork
using UnityEngine; using System.Collections; public class NetworkTest : MonoBehaviour { ;//端口号 strin ...
- Javascript 控制 让输入框不能输入 数字
监听keypress事件.判断如果是数字的话阻止浏览器冒泡 <input type="text" id="test"> <script typ ...
- 使用 FireMonkey 构建优秀专业 Android 应用的10点提示
原文链接:http://www.firemonkeyx.com/ten-tips-for-building-stunning-professional-android-apps-with-firemo ...
- 7z文件格式及其源码的分析(五)
这是7z文件格式及其源码的分析系列的第五篇. 上一篇讲到了7z文件压缩流程.最近太忙了,好久没更新,都快忘了写到哪了.:) 这一篇就说说7z文件的尾头的生成方式吧. 上一篇已经讲了尾header的结构 ...
- 关于.net和java des加密
在.net和java环境中对于des加密,有几点要协同的地方: 密钥和密钥向量Key IV 加密模式CipherMode 填充模式PaddingMode 密文编码方式 下面一段.net的des加密方式 ...