Generating a recursive md5sum.txt from a directory...
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9
Rep:
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.
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.
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9
Original Poster
Rep:
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.
Distribution: OS: Linux Mint KDE, Web Browser: Firefox 30 w/custom usergant string to enable Netflix via:Pipelight
Posts: 9
Original Poster
Rep:
Quote:
Originally Posted by unSpawn
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.