Linux获取文件MD5码命令md5sum详解

描述

概述

md5sum 用于计算和校验文件的MD5值。

md5sum 常常被用来验证网络文件传输的完整性,防止文件被人篡改。在日常工作当中,我们可以用来判断系统中的重要文件是否被篡改。传文件给别人时确认是否一致。

还可以使用使用 md5sum 生成文件或用户的密码。

语法
 

该命令的语法如下:

md5sum [选项] 文件
新命令老套路先help

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)

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     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 space, a character indicating input mode ('*' for binary,

' ' for text or where binary is insignificant), and name for each FILE.

GNU coreutils online help:

Full documentation at:

or available locally via: info '(coreutils) md5sum invocation'

复制代码

Linux
主要参数讲解

选项 说明
-b 以二进制模式读取文件
-t 以文本模式读入文件内容
-c 根据已生成的md5值,对现存文件进行校验
-w 检查输入的md5信息有没有非法行,若有则输出相应信息
–status 校验完成后,不生成错误或正确的提示信息,可以通过命令的返回值来判断


实例

md5sum libnim.so

5ef2e45e1890736413407299ecc2786a  libnim.so

复制代码



Linux

  审核编辑:汤梓红

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分