How To Check Integrity Of Files In Linux? – POFTUT

How To Check Integrity Of Files In Linux?


In today IT world everything connected and a lot of data is being downloaded from the internet or over networks. This may create some minor problems. The data downloaded may be corrupted or there may be some intruders in network and with the man of the middle attack may change our files. There are different solutions for this but the simplest and fastest solution is using hash algorithms to verify file integrity. There are the different hash function to use but MD5 and SHA1 are popular ones.

nmap
nmap

Download Nmap

We will download nmap package named nmap-7.31.tgz from nmap.org . We will use this file as an example where this file hash is already provided by Nmap web site.

$ wget https://nmap.org/dist/nmap-7.21.tgz
Download Nmap
Download Nmap

Get Hash Values From Site

We will calculate hash of downloaded file nmap-7.31.tgz 

Get Hash Values From Site
Get Hash Values From Site

Here are the contents of the hash file about the downloaded Nmap source file with the name of nmap-7.31.tgz.digest.txt.

Get Hash Values From Site
Get Hash Values From Site

Calculate Hash

We will use sha1sum to calculate SHA1 , md5sum to calculate MD5 sha24sum to calculate SHA256 and sha512sum to calculate SHA512 of the given file.

$ sha1sum nmap-7.31.tgz
$ md5sum nmap-7.31.tgz
$ sha224sum nmap-7.31.tgz 
$ sha512sum nmap-7.31.tgz
Calculate Hash
Calculate Hash

As we see newer SHA version creates longer hash because they are more secure and complex. If we check the calculated hash and web site provided hash we can see that everything is OK.

LEARN MORE  Netcat (nc) Command Tutorial With Examples

Leave a Comment