checksum命令 linux_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 inbinary mode-c, --check read MD5 sums from the FILEs and check them--tag create a BSD-style checksum-t, --text read intext 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 forimproperly 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 describedin 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 ('*' forbinary,

spacefor text), and name foreach FILE.

GNU coreutils online help:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值