Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
/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?

share|improve this question
    
If you want to checksum a directory (or rather all files in it), using cfv will give better results. –  Hubert Kario Jan 5 '11 at 13:43

1 Answer 1

up vote 7 down vote accepted

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 do tar 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.

share|improve this answer
    
Mention that tar files not only contain the files but also information about them like dates, owner, permission, etc. –  LatinSuD Jan 5 '11 at 9:01
    
@LatinSuD: Done. Thanks. –  Dennis Williamson Jan 5 '11 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.