LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I check md5sum for a directory tree against a list of checksums? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-check-md5sum-for-a-directory-tree-against-a-list-of-checksums-4175522455/)

slacker_ 10-17-2014 03:12 PM

How do I check md5sum for a directory tree against a list of checksums?
 
I ran a md5 checksum on a directory tree generating a list of all md5sums for every file in that dir tree. Now I need to check a copy of that directory against the list. In the terminal I'm sitting at ~/bak-dir/ which has the DIR that I'm checking.

The file is formatted like this:

Code:

[md5sum string] /DIR/path/to/file.txt
So I run the following:

Code:

laptop:~/bak-dir/$ ls -a
DIR    checksum_list.md5
:~/bak-dir/$ md5sum -c checksum_list.md5
/DIR/path/to/file.txt: FAILED open or read

Can anyone help me figure out what's going wrong?

c0d3d 10-18-2014 08:38 AM

According to that error message, it may not be able to read the contents of the folder. This command may do the trick:
Code:

sudo chmod -R a+r DIR/
Now try running the directory checksum again.

slacker_ 10-18-2014 02:56 PM

Did that, ran the check again, and got the same thing. So I tried to cd into DIR and run it from in there with the file.md5 in the parent directory:

Code:

:~/bak-dir/DIR/$ md5sum -c ../file.md5
And all the files returned "md5sum: /DIR/file.foo: No such file or directory"

So now what?

c0d3d 10-18-2014 03:00 PM

Wait a second, "/DIR"? But the folder is within ~/bak-dir. Try moving the DIR folder to / (the root folder) and try again.

rknichols 10-18-2014 03:06 PM

Or,
Code:

sed -e 's%/DIR%DIR%' file.md5 | md5sum -c -
As you are now discovering, generating md5sum files, tar archives, etc., with absolute paths is generally a bad idea.

c0d3d 10-18-2014 03:07 PM

Yeah, that would work too. So, did it work?

slacker_ 10-18-2014 10:30 PM

It worked! And no errors. Thanks SO much for all the help!

c0d3d 10-19-2014 01:04 PM

You're welcome :).


All times are GMT -5. The time now is 01:31 AM.