Fork me on GitHub

Linux md5sum 命令

Linux md5sum 命令


 

通过 Linux 的 md5sum 命令,可以对指定的文件,计算出唯一的一个MD5值(128bit)。

通过比较文件前后的MD5值,可以判断文件是否发生变化(是否被修改过)。


 

1、md5sum 命令使用方式(通过md5sum --help查看):

复制代码
Usage: md5sum [OPTION]... [FILE]...
Print or check MD5 (128-bit) checksums.
With no FILE, or when FILE is -, read standard input.

  -b, --binary         read in binary mode
  -c, --check          read MD5 sums from the FILEs and check them
      --tag            create a BSD-style checksum
  -t, --text           read in text mode (default)
  Note: There is no difference between binary and text mode option on GNU system.

The following four options are useful only when verifying checksums:
      --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     display this help and exit
      --version  output version information and exit

The sums are computed as described in RFC 1321.  When checking, the input
should be a former output of this program.  The default mode is to print
a line with checksum, a character indicating input mode ('*' for binary,
space for text), and name for each FILE.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'md5sum invocation'
复制代码

 

2、计算一个文件的 MD5 值

1)新建一个文件test.txt,内容为 Hello, md5sum.

使用如下命令,生成改文件对应的 MD5 值

md5sum test.txt > md5.out

 

2)此时会在当前目录下看到生成的 md5.out 文件

 

3)查看改文件对应的 MD5 值

cat md5.out

 

4)使用如下命令,比较文件的 MD5 值是否发生变化

md5sum -c md5.out

 

5)当修改test.txt 文件,增加 Modify 单词,再次对比 MD5 值,会发现不一致

 

6)BSD格式查看 MD5 值

md5sum --tag md5.out 

 

posted @   龙凌云端  阅读(1271)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示