Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux/Unix md5sum 指令驗證檔案完整性與比對差異

編輯:關於 Linux

md5sum 為 Linux/Unix 內建工具,依據 MD5 演算法產生 128 位元(32 字元十六進位)指紋,用於驗證檔案傳輸完整性、比對兩檔案是否相同、偵測檔案是否被竄改。

常用參數

  • -b:二進位模式讀取
  • -t:文字模式(預設)
  • -c:從檔案讀取 MD5 進行校驗
  • --status:配合 -c 僅回傳狀態碼不輸出訊息
  • -w:校驗時警告格式錯誤行

實務範例

  1. 產生單一檔案 MD5:md5sum file.txt
  2. 比對兩檔案:md5sum file1 file2,比較輸出的雜湊值是否相同。
  3. 批次驗證:md5sum -c checklist.md5,checklist.md5 內含「雜湊值 檔名」每行一筆。
  4. 偵測檔案變動:定期產生重要檔案 MD5 清單,排程比對發現異動。

注意:MD5 已不適合加密用途,但檢驗檔案完整性仍足夠可靠。

Copyright © Windows教程網 All Rights Reserved