How To Check or Verify File Integrity

The best way to verify file integrity (i.e. large file downloaded from internet) is by generating a Checksum/Hash and check if it matches.

BaSH

[boss@scriptingbox ~]# md5sum servers.txt
1aefcf0fd2b48f0b2e9633bdf27c9f95 servers.txt

PowerShell

PS C:\Users\system.team\Documents> Get-FileHash -Algorithm MD5 .\servers.txt | ft -AutoSize

Algorithm Hash Path
--------- ---- ----
MD5 1AEFCF0FD2B48F0B2E9633BDF27C9F95 C:\Users\system.team\Documents\servers.txt

TIP

If you are looking for a specific file when you know its md5 checksum it’s possible to find it even if was renamed or moved with a simple script like this. Sometimes Malware or Virus are identified by their hash/checksum.

[boss@scriptingbox]:/home/boss# find /home -type f -exec md5sum {} + | grep 'e4216edb5b97abea13dc3efa9f240406'
e4216edb5b97abea13dc3efa9f240406  /home/boss/server.txt

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.