【Shell命令】Linux获取文件MD5码命令md5sum浅析
【Shell命令】Linux获取文件MD5码命令md5sum浅析概述md5sum 用于计算和校验文件的MD5值。
md5sum 常常被用来验证网络文件传输的完整性,防止文件被人篡改。在日常工作当中,我们可以用来判断系统中的重要文件是否被篡改。传文件给别人时确认是否一致。还可以使用使用 md5sum 生成文件或用户的密码。
语法
该命令的语法如下:md5sum [选项] 文件
新命令老套路先help
md5sum --help
Usage: md5sum ... ...
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-missingdon'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
--versionoutput 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: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/md5sum>
or available locally via: info '(coreutils) md5sum invocation'
主要参数讲解
选项说明
-b以二进制模式读取文件
-t以文本模式读入文件内容
-c根据已生成的md5值,对现存文件进行校验
-w检查输入的md5信息有没有非法行,若有则输出相应信息
–status校验完成后,不生成错误或正确的提示信息,可以通过命令的返回值来判断
实例
md5sum libnim.so
5ef2e45e1890736413407299ecc2786alibnim.so
生成文件md5值:
date | md5sum
ca85c81605f47386eae75781590ae2d3- 校验多个文件
如果要校验多个文件,命令格式如下:# 语法md5sum 文件1 文件2 文件3 ...
# 示例md5sum test.txt two.txt one.txt
页:
[1]