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來校驗生成文件校驗碼,來發現文件傳輸(網絡傳輸、復制、本地不同設備間的傳輸)異常造成的文件內容不一致的情況。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM