I expect you've gotten a dozen responses to this, but here's another.  =)  

Use the 'find' command to find all the files you want to identify, and then
have it run the md5sum program on them.

You'll want to use:

find directory-to-md5 -type f -exec md5sum {};

The -type f keeps find from finding pipes and directories and things.

Find is a powerful, useful, confusing tool.  Read the man page for all the
gory details.

You'll probably have to escape some of the punctuation with backslashes,
depending on your shell.  Here's a sample run of the find command off of
something in my home directory.  I use bash so I had to escape {, }, and ;.

wwonko@holly:~ > find ./bb/ -type f -exec md5sum \{\} \;
07d05351b4d0a22355bb8f6153cc1494  ./bb/oekaki132e.zip
659f5e7d7c2447f765203df6a67e97d6  ./bb/pbbsao147.zip
659f5e7d7c2447f765203df6a67e97d6  ./bb/bbs/pbbsao147.zip
927a96b2955d7a1ce8ea886179960bf9  ./bb/bbs/PaintBBS.jar
1742b3beedd999a823af95a693fa93aa  ./bb/bbs/oekakibbs.html
9c5cd098ccc51bee3749d05fa2a7d1cf  ./bb/bbs/Readme_Shicyan.html
7d688306677b99ec34cf68ef93562381  ./bb/bbs/jcode.pl
56d9d8cb6f73a472fc9f2740bab6ea10  ./bb/bbs/readme.txt
84d91a04411150d82eed264c65ed40da  ./bb/bbs/oekaki.cgi
0da15c72780df81382311ed445142559  ./bb/bbs/oekakibbs.cgi

Redirect that in to a file and you should get what you need.

That should actually answer the question you asked.  You might also find
this related thing interesting.

A friend of mine, Jim Bennett, showed me another way you can quickly check
system integrity, at least on an RPM based system.  Have RPM compare the md5
of the files on disc to the md5 stored in the RPM database.  This can find
corruptions and any replaced or changed files.

Naturally, configuration files and the like are supposed to change, so you
can't simply take anything that has changed as being a problem, but it gives
you an interesting way to look at all the vendor-installed parts of your
system, quickly.

You use this by using rpm --verify along with some package selection rules.

I tend to use '-f' to verify the package that includes a specific file...

rpm --verify -f /bin/ls

Or perhaps to check every package on the system:

rpm --verify -a

The rpm query commands will let you see which packages you'll be getting
with the commands before you stun yourself with too much output.

No news is good news.  A row of all dots for each file is also good news.  A
bad MD5 will list a '5', other things will cause other letters to show up.
See man rpm for more information than you probably ever wanted.

Lots of noise isn't always a bad thing; you'll have to know what is 'normal'
for your system.  On my system running a check of the package
sendmail-8.11.3-68 causes pretty much every file to be reported as corrupted
or missing.  This isn't a problem, because I know I've replaced sendmail
with another MTA, and that I was lazy and didn't do it in a way that the RPM
database knows about.

This works for any vendor provided RPM and any RPM you build and install
yourself.  My friend Jim makes a point to put any software he adds to his
system in RPMs and to install them normally so that he can use this tool as
a quick way to verify that things are healthy.

Not quite the question you asked, but perhaps interesting nonetheless.

Louis Erickson
IT Tools Developer,
Ariba, Inc.


> -----Original Message-----
> From: Mark G. Spencer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 25, 2002 9:56 AM
> To: [EMAIL PROTECTED]
> Subject: MD5'ing a directory tree in Linux?
> 
> 
> Is it possible to MD5 all the items in a directory tree using 
> Linux?  I
> am on a Redhat 7.3 workstation.  I have read the man and info file for
> MD5SUM and also tried to run it against a directory without 
> success.  I
> get the error "Is a directory" which is very self explanatory.
> 
> So .. Is there another MD5 utility with more flexibility?  I basically
> need to MD5 every file individually in a large directory tree with the
> output redirected to a text file showing the path, filename, 
> and hash of
> every file in that directory tree.
> 
> Thanks for the assistance,
> 
> Mark
> 
> 

Reply via email to