/tmp/file.txt
tar cvf 1.tar tmp
md5sum 1.tar
c32dc6f04ff02b371129dd4aa923cc12
rm 1.tar
cd tmp
touch test.txt
rm test.txt
cd ..
tar cvf 1.tar tmp
md5sum 1.tar
f9204f04ff02b300130ee4aa234aa78
i dont understand why these two check sums are different. how does adding a file and then removing it from the tmp directory create a "different" tar file?
When you create and delete the test.txt file the modification time of the directory is updated. That's the difference in the tar file that causes the checksum to be different.
You can see the affect by doing
ls -ld tmp
before and after touching and removing the file. You can also see it if you dotar tvf
before and after.Edit:
As LatinSuD mentioned in a comment,
tar
files contain date, owner and permission information about the files and directories contained within.