← Back to Kurakani

LINUX/UNIX Geeks - Please Advise!

Original Post

I inadvertently did the following: mv ../lib* . from /local (which really means - all files inside /lib/ got moved to /local/) .. and now I CANNOT get into the box. 'Access Denied' as a root or a regular user. However, I still have the currently running SSH session, which doesn't let me do much - except for cd, pwd, echo and couple other basic commands (no cp, mv, ls etc). Can't sudo either (not that it would help much). Anyone has a clue - workaround? ~@~

Saajha
Jul 17, 2008 4:52 PM · 30,132 views
30 Replies · Showing 21 - 30
Page 2 of 2
katmandude Jul 17, 2008 9:40 PM
mv does not mean you moved it. It means it got renamed. e.g. mv x x.bkp means file x got renamed x.bkp. So when you did -> mv ../lib* . from /local, I believe the files with beginning with "lib" became ".". I believe cp would have copied the files. So I think booting the server with a live cd, then mounting the file systems and then doing, cd to /local then doing mv again to all the renamed files might help. I guess I would make sure how the files will get renamed back by checking the contents of the . dir... What do you have under /lib? are there files simply named "."?? K'dude
oldmaven Jul 17, 2008 10:04 PM
. Katmandude,$mv ../lib* . from /usr/local/ would copy(move) the folder /usr/lib into /usr/local as /usr/local/lib.Saajha, Can you think of a way, you can simply ask the OS to boot using /usr/local/lib instead of /usr/lib to find its libraries , provided the permissions are ok on the copied files. Something like LIB_PATH or editing init interfaces? I guess that'd still be the other workaround. PS: LD_LIBRARY_PATH / ldconfig ??? These might come handy, the command of these sorts. # /sbin/ldconfig -n /usr/local/lib Last edited: 17-Jul-08 10:19 PM
katmandude Jul 17, 2008 10:47 PM
You are right Oldmaven...rebuild.
Brain Malfunction Jul 17, 2008 11:11 PM
1. You said it is not production box, not much critical, so take it easy.. grab a cup of black coffee and take a long deep breathe. And dont forget to thank god, it was mv command, not rm. 2. Talk to your boss, dont feel embarrassing. Shit happens.. specially in sys admin job. He will understand it. 3. No backup, no root privilege and working on remote machine = You can not do anything in this case. 4. Guys, he is saying- he can not issue any system-level commands, so forget about rebooting / installing with LIVE CD . Unless there is some back-up/restore script (I strongly believe it should be there), he can not write back to /lib/ as a normal user. 5. Back up what you have copied to your /local directory. Someone with su access will restore back to /lib/. 6. 'mv does not mean you moved it. It means it got renamed.' - Please dont advise unless you know what you are saying.. 7. You learn the most when you make mistakes (as long as it is not so disastrous that you will be screwed up.. )
Saajha Jul 18, 2008 9:16 AM
@BM: rm or mv -- no difference in this case; these are the libraries that come with OS -- can copy them from a different machine or a CD. @oldmaven: I like your idea of making the OS look for those libraries under /local/lib instead of /lib during bootup. But that requires editing the script - while no vi or nano gets recognized. Also /sbin/ldconfig couldn't execute. Do you (or anyone) know if a text file can be pushed using echo? @k'dude: I agree with your explanation on mv and 'rename' being the same (mv is what you really use in *NIX to rename a file) --- someone told me the other day that one of the libraries I moved (renamed) was PAM library, which plays role in authentication; and since the system doesn't find it on its default location (with default name), it cannot verify authentication. ~@~
bond_oo7 Jul 18, 2008 9:18 AM
having root user as local does not have anything to with /lib folder being moved.. user information is stored in /etc/ folder under passwd file. which flavor of unix r u using? try to grep the passwd file for root and look for UID, its the 3rd field separated by ";" root should have uid of "0". in order to run other commands you may try to get into the /lib/ folder that you moved your content into then envoking those commands.. (if i am understanding your question right) Good Luck!
oldmaven Jul 18, 2008 4:06 PM
. I am finding it hard to believe that echo works but cp doesnt work, when i believe they are from the same directory. /bin/cp , /bin/echo , at least on this not-enterprise edition. Are they in yours? If you find the magic place to change the library path besides rebuilding kernel, you can easily include it to the end of the script file with echo as $echo "LD_LIBRARY_PATH=working/directory" >> script.file (sth like this to append to the script) There was one which modifies dynamic library load path of compiled programs and libraries, which you can use for your pam.so if you arent getting the PAM modules for authentication.Its called "chrpath" , but i guess you dont have it installed by default on your machine. Could you please provide error msgs as well , as what it says . Also possibly point out what scripts work and what dont, which privileges you have, which you dont. And we can take these discussions off Sajha too, into a total technical arena, if you like.
Saajha Jul 18, 2008 9:31 PM
@oldmaven -- there's no need to find a separate sandbox for this discussion. I bet San wouldn't mind us exchanging our views here. This is supposed to be an open forum (sabaiko sajha), No? Anyways, here's a quick proof of concept I prepared earlier today, mimicking my original steps. Even though this was done on Fedora Core 6, I could replicate the exact same steps/outcome as on RHEL 5 (as anticipated). Want to take a look? http://www.2shared.com/file/36... @bond_oo7, I can't do grep anymore on this box! You probably didn't read the whole thread? Regardless, I should thank you for the advice! Please keep 'em coming!!
oldmaven Jul 19, 2008 1:19 PM
. I think i got it. $ /local/lib/ld-linux.so.2 --library-path /local/lib /bin/ln -s /local/lib/ /lib Let us know if it works!
Saajha Jul 20, 2008 11:14 AM
DUDE -- Two thumbs way up for this effort of yours!!!! YES IT WORKS !!!!!!!!! It did fine on the virtual machine that I did POC earlier. I'll reach my 'original' box first thing tomorrow morning and replicate it! However there's a possible caveat.... This box needs users to sudo into root to do almost everything. When I did mv ../lib* . , I did it as root. Now that I am a regular user, the question is whether or not this command would execute when I run it as myself. In any case, kudos to oldmaven --- my issue is more of an experimental fun than a necessity at this point (a new machine has already been shipped to the data center). I can always use this one as a load balancer if we decide to keep it there! Thanks everyone involved in this discussion thread for your intiative and input. Technology Rocks ~eh!! ~@~
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant