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查看文件乱 ...
随机推荐
- Oracle——分页查询
查询员工表中,工资排名在10-20之间的员工信息. select * from( select rownum rn ,employee_id,salary from ( select employee ...
- shared_ptr / weak_ptr 代码片段
参考<<Boost程序库完全开放指南>> shared_ptr 类摘要(只列出了常用的部分)和相关说明 template <class T> class shar ...
- [operator]ELK6 index pattern的问题
完成了EL/FK的搭建之后,在kibana的主页只能看到默认的索引? 其实这个索引名字的设置是在logstash-smaple.conf(elk6.4)里的设置,比如我这样设置 input { bea ...
- kalilinux系统设置
echo LANG="zh_CN.UTF-8" > /etc/default/locale
- 盒子模型 以及CSS的box-sizing属性。
盒子模型有两种 一种是 内容盒子模型 一种是边框盒子模型. 内容盒子模型(标准盒子模型)由width和height中指定的元素的尺寸不包括内边距和边框 仅是指的内容的实际尺寸: 网上搜索了两张配图不错 ...
- JDK8新特性:使用stream、Comparator和Method Reference实现集合的优雅排序
大家对java接口Comparator和Comparable都不陌生,JDK8里面Comparable还和以前一样,没有什么改动:但是Comparator在之前基础上增加了很多static和defau ...
- 下了个蓝屏代码查看工具,就中病毒了。。。什么鬼病毒,竟然还是用的VBS
扫描所有盘下面的html文件,加入VBS脚本...真是奇葩,多少年前的病毒了... http://files.cnblogs.com/files/guangshan/lpdmcxq.rar 这个是病毒 ...
- 基于flask的轻量级webapi开发入门-从搭建到部署
基于flask的轻量级webapi开发入门-从搭建到部署 注:本文的代码开发工作均是在python3.7环境下完成的. 关键词:python flask tornado webapi 在python虚 ...
- STM32 IAP+Ymodem功能实现(参考官方代码)
IAP:在线升级代码 ,通俗的讲就是通过USART,IIC,或者SPI,USB等等,方式,在程序中升级程序,一般用在远程升级,或者是在PCB板子都安装到模具之后还需要升级代码,这样我们就需要,通过IA ...
- layui与多级联动返填
<script> layui.use(['form', 'layer'], function () { $ = layui.jquery; var form = layui.form() ...