LinuxQuestions.org
Review your favorite Linux distribution.
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 07-29-2014, 10:52 PM   #1
Kaiji
LQ Newbie
 
Registered: Jul 2014
Location: Somewhere on the planet :)
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9

Rep: Reputation: 0
Lightbulb Generating a recursive md5sum.txt from a directory...


First off, 'Thank You' for making a useful forum, it is much appreciated.

Well simple task generate an md5sum.txt for a large directory..... (for an armhf rootfs for my tablet I generated using debootstrap) It seems like it should be something as simple as this:
Code:
 # md5sum -rb ./*
.. or something really close to that... but any how it is not so simple. But alas I was able to come to a solution easily using a web search which brought me here to find the answer... which is:
Code:
# find . -type f -print0 | xargs -0 md5sum -b
.. I found the answer here at LinuxQuestions.org - here Thank You Garda for your post on this subject.

Any how I thought instead of having to type all that out again, the next time I need to generate an md5sum.txt I whiped up a very simple shell script, named md5summer, then saved it in the /usr/bin folder. I named it md5summer with no .sh extention so it would be easy to remember. and I tested it out a few times before I made this post, and it worked great for me.

This is what I have for the md5summer file:
Code:
#!/bin/bash
export XDIR=$1
find $XDIR/ -type f -print0 | xargs -0 md5sum -b 2>&1 |tee $XDIR/md5sum.txt
After saving the file at /usr/bin, then be sure to type this at the terminal:
Code:
# chmod +x /usr/bin/md5summer
To make it excecutable, then the script works really simple, just type at the terminal:
Code:
# md5summer .
.. To create an md5sum.txt in your current directory. Or if you are not in the same directory as you want to generate the md5sum.txt in, then it is:
Code:
# md5summer /home/myname/somedirectoryname
.. For example.

And vuala. you will get a screen output of the md5sums, and a md5sum.txt file for the directory you chose

To verify your files against your md5sum.txt checksums, is easy to remember, it is:
Code:
# md5sum -c md5sum.txt
at some later point, when they need to be verified.

Thanks again everyone, as I posted in my Introduction post, I will ocasionally try to find small bits of useful information, and begin to try adding a little, as I do use a lot of the information I find, need, and learn.

- Kaiji
 
Old 07-30-2014, 08:44 PM   #2
Kaiji
LQ Newbie
 
Registered: Jul 2014
Location: Somewhere on the planet :)
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9

Original Poster
Rep: Reputation: 0
Question Conundrum...

Hello again, it is me Kaiji with a question on this subject again

I notice a minor conundrum with the shellscript 'md5summer' from the previous post, and it goes like this, once the md5sum.txt file is created it will contain one entry so far is has always been the first entry with a checksum for the newly created md5sum.txt with a wrong md5 checksum (since the file has a different checksum from when it was generated, then different after the data inside changed, from adding all the lines of checksums). Then even if you generate a new checksum for md5sum.txt, and enter the new data on that line, then that still causes the file md5sum.txt to again have a new checksum.... lol. ity is easy enough to just disreguard that single entry. But what I would like to know now, is if there is a way to correct this? Somehow get the correct checksum for the file md5sum.txt entered into the same file. It would have to somehow get the checksum of this file after it has all the generated data, including the correct checksum for itself....

Seems like a catch 22 to me as every change in the data creates a new checksum, and entering it into the file does this making that entry again wrong...

So if this is possible to do please post it here, I am very interested in weather or not it can be done. I am currently fully decided that it can not be done. To improve the scriptfile I think I should instead find a way to generate the file without including that entry.

And as always, Thank You Much

- Kaiji
 
Old 07-31-2014, 12:47 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
That's why md5sum files are not included inside of the packages they're used to verify. The md5sum is a separate file from the archive.
 
Old 07-31-2014, 02:03 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Ow, and BTW, for recursive hashing see 'man md5deep'. Way easier.
 
2 members found this post helpful.
Old 07-31-2014, 07:22 PM   #5
Kaiji
LQ Newbie
 
Registered: Jul 2014
Location: Somewhere on the planet :)
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by unSpawn View Post
Ow, and BTW, for recursive hashing see 'man md5deep'. Way easier.
I had to install, but that was quick and easy
Code:
# apt-get install md5deep
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  md5deep
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 662 kB of archives.
After this operation, 1,407 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ saucy/universe md5deep amd64 4.2-1 [662 kB]
Fetched 662 kB in 0s (942 kB/s)  
Selecting previously unselected package md5deep.
(Reading database ... 266951 files and directories currently installed.)
Unpacking md5deep (from .../md5deep_4.2-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up md5deep (4.2-1) ...
Thanks for the tip

You are absolutely right.. After checking it out, Way easier.

- Kaiji

Last edited by Kaiji; 07-31-2014 at 07:50 PM.
 
  


Reply



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
generating an md5sum.txt recursivly from a directory. Kaiji Linux - General 1 07-30-2014 02:24 PM
Generating md5sum checksum files in each directory Slim Backwater Linux - General 2 04-15-2014 01:57 AM
How to create md5sum for a directory? SentralOrigin Linux - Software 13 04-09-2012 12:14 PM
generating packages.txt etc in slapt-get repo dr.karabas Slackware 3 06-09-2008 09:47 PM
md5sum recursive on Centos 4.4 shaamone Linux - Software 1 04-08-2007 09:16 AM

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

All times are GMT -5. The time now is 12:08 AM.

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