Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
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.
We're running RedHat Etnerprise Linux3 on a Dell box.
Last week, somebody deleted the /usr/bin directory.
Unfortunately, we have no backup of that directory.
We do have the original installation media.
Is there a way to repair or rebuild the /usr/bin directory from that without actually reformatting the drives and starating from scratch?
Is there a way to repair or rebuild the /usr/bin directory from that without actually reformatting the drives and starting from scratch?
Why not?:
Code:
cd $TEMP
rpm -qa --dump|grep /usr/bin|awk '{print $1}'|while read bin; do
rpm -q --whatprovides "$bin"; done|sort|uniq|while read name; do
find /mountpoint -type f -name ${name}\*.rpm|head -1|while read rpm; do
rpm2cpio $rpm > ./${name}.cpio && \
cat ./${name}.cpio|cpio -ivd --no-absolute-filenames "./usr/bin/*"
rm -f ./${name}.cpio; done; done; done
Now your binaries are in $TEMP/usr/bin. To help you install them and change ownership and access rights you can generate them from the RPM database as well:
Code:
rpm -qa --dump|grep /usr/bin|awk '{print $1, $5, $6, $7}'|while read bin p o g; do
[ "${p:2:1}" = "2" ] && d="#symlink"; echo "${p:3} $o $g $bin ${d}"; done
Using output to actually install the binaries "is left as an exercise to the reader".
All replies welcome, please email direct
Simple rule, no exceptions: Ask question here, get answer here.
Last edited by unSpawn; 08-16-2006 at 01:14 PM.
Reason: //Have keybd, can't type
I just wanted to try this out, so I deleted my /usr/bin
Neat!
I get an errorsyntax error near unexpected token 'done'
Bummer.
Which "done"? You did replace the "/mountpoint" placeholder with the directoryname where your rpms reside in? Can you run the script as "sh -x scriptname 2>&1|scriptname.log" and post the contents here (please skip posting repeats)? Thanks.
ah, well, if this is causing you problems, dont reply back.
If something causes problems then one *should* post.
I will reinstall, was just doing it to learn something.
It's so fsckin simple. I asked you twice to post back debug output which you didn't on both occasions. If you can't or won't cooperate by posting debug output then tell me how I am supposed to determine what goes wrong on your box? Cuz my ESP is at an alltime low.
ok I figured out why the script doesnt workout.
uniq and find both commands are in the /usr/bin directory, so this wont work.
although uniq can be done by a sed command
sed '$!N; /^\(.*\)\n\1$/!P; D'
next, you would need rpm2cpio which again is in /usr/bin/
now this is totally awesome, I finally got the script to work and now my dead system is backup with everything.
cool unspawn, your the best!
didnt know rpm could do this!
anyway, what I did was got linux rescue mode and copy the files find, rpm2cpio,uniqetc. to my deleted /usr/bin. rebooted, ran unspawn's script and I got back my /usr/bin, totally awesome.
one thing though, I ran the second script it gives all command not found errors, I guess its missing the work "chmod" in it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.