LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-17-2014, 03:12 PM   #1
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Rep: Reputation: 3
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?
 
Old 10-18-2014, 08:38 AM   #2
c0d3d
Member
 
Registered: Aug 2012
Posts: 74

Rep: Reputation: 12
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.
 
Old 10-18-2014, 02:56 PM   #3
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
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?
 
Old 10-18-2014, 03:00 PM   #4
c0d3d
Member
 
Registered: Aug 2012
Posts: 74

Rep: Reputation: 12
Wait a second, "/DIR"? But the folder is within ~/bak-dir. Try moving the DIR folder to / (the root folder) and try again.
 
Old 10-18-2014, 03:06 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
1 members found this post helpful.
Old 10-18-2014, 03:07 PM   #6
c0d3d
Member
 
Registered: Aug 2012
Posts: 74

Rep: Reputation: 12
Yeah, that would work too. So, did it work?
 
Old 10-18-2014, 10:30 PM   #7
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
It worked! And no errors. Thanks SO much for all the help!
 
Old 10-19-2014, 01:04 PM   #8
c0d3d
Member
 
Registered: Aug 2012
Posts: 74

Rep: Reputation: 12
You're welcome .
 
  


Reply

Tags
md5, md5sum



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
md5sum check AngryAngry Slackware 11 01-02-2012 01:50 PM
How to list the directory tree? thomas2004ch Linux - Newbie 20 09-28-2009 06:28 PM
How to check md5sum satimis *BSD 5 05-05-2007 12:17 AM
How to generate a list of MD5 checksums? General Linux - Software 2 06-10-2006 09:59 PM
md5sum check? digitalbanana Linux - General 1 07-01-2002 04:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration