linux md5sum命令

 

 

md5sum命令用于生成和校验文件的md5值

 

生成文件md5值

[root@cdncenter ~]# ll
total 0
-rw-r--r-- 1 root root 0 Oct 19 21:42 1.txt
-rw-r--r-- 1 root root 0 Oct 19 21:44 2.txt
-rw-r--r-- 1 root root 0 Oct 19 21:44 3.txt

 

[root@cdncenter ~]# md5sum 1.txt 
d41d8cd98f00b204e9800998ecf8427e  1.txt

 

 

 

 

 

使用通配对多个文件进行md5

[root@cdncenter ~]# md5sum *
d41d8cd98f00b204e9800998ecf8427e  1.txt
d41d8cd98f00b204e9800998ecf8427e  2.txt
d41d8cd98f00b204e9800998ecf8427e  3.txt

 

 

相同内容的文件的md5一样。如下我先对文件进行复制,然后对同内容不同名的文件进行md5,md5值一样

[root@cdncenter data]# touch data
[root@cdncenter data]# cp data data.bak
[root@cdncenter data]# ll
total 0
-rw-r--r-- 1 root root 0 Oct 19 22:04 data
-rw-r--r-- 1 root root 0 Oct 19 22:05 data.bak

[root@cdncenter data]# md5sum
* d41d8cd98f00b204e9800998ecf8427e data d41d8cd98f00b204e9800998ecf8427e data.bak

 

 

 

总结

通过md5sum来校验生成文件校验码,来发现文件传输(网络传输、复制、本地不同设备间的传输)异常造成的文件内容不一致的情况。

 

posted @ 2018-10-19 22:07  minger_lcm  阅读(3945)  评论(0编辑  收藏  举报