Always Geeky

Knowledge base for various geeky topics
 

+menu-

Using hashdeep to confirm two directories match

First, use hashdeep to capture the hash of the first directory:

$ hashdeep -b -r /home/user/one/ > one-results.txt

Then do the same for the second directory:

$ hashdeep -b -r /home/user/one > two-results.txt

Now you need to compare the two resulting files. Their order is likely to be different, so you will need to sort them first.

$ sort one-results.txt > one-results-sorted.txt

$ sort two-results.txt > two-results-sorted.txt

$ diff one-results-sorted.txt two-results-sorted.txt

If the directories match, the only output of the diff command will be the headers showing the two files you are comparing. Like this:

10c10

\ ## $ hashdeep -b -r /home/user/one — \ ## $ hashdeep -b -r /home/user/two


You can use the -a command of hashdeep, but that will only if the directors are the same or not, it won’t show you what is different between them.

The -b flag is important – without this, hashdeep will store the full file path in the output files, which will never match between two directories. Using the -b flag ensure that only the filename is saves, not the full path, and this can be checked against different directories.

This entry was posted in Firewalls and tagged . Bookmark the permalink.

 

Leave a Reply