tar.gz of the same file is different?
1 min readMar 19, 2021
I download stuff from the internet and would like to checksum.
The download script appear to extract itself already.
So I try to archive it back and try to run a simplemd5sum
.
But it’s not the same
md5
sum !!!
Experiment
I download the package flyway
$ ls
flyway-7.7.0
Then I going to make a tar
ball and also zipping with tar
command
$ tar -cf flyway-7.7.0.tar flyway-7.7.0
$ tar -cf flyway-7.7.0-2.tar flyway-7.7.0
$ gzip flyway-7.7.0.tar
$ gzip flyway-7.7.0-2.tar
$ md5sum *.gz
9e7df6ead10ba08509c522699f9abb9f flyway-7.7.0-2.tar.gz
4364ea9a31b542c9f93b0ccc6dc93fcd flyway-7.7.0.tar.gz
This also different !
Reason
I clean up a bit.
$ rm *.gz$ tar -cf flyway-7.7.0.tar flyway-7.7.0
$ tar -cf flyway-7.7.0-2.tar flyway-7.7.0
I try to gzip
it again but this time with -n
flag
$ gzip -n flyway-7.7.0.tar
$ gzip -n flyway-7.7.0-2.tar
$ md5sum *.gz
66e04e783300b4297ba18bf263e7c767 flyway-7.7.0-2.tar.gz
66e04e783300b4297ba18bf263e7c767 flyway-7.7.0.tar.gz
Here we are. The -n
flag is
-n, --no-name
do not save or restore the original name and timestamp
This is because the default option include name and timestamp
.
So it make the file sum change !
Hope this help.
Cheers !