LINUX/UNIX Geeks - Please Advise! - Sajha Mobile
SAJHA MOBILE
LINUX/UNIX Geeks - Please Advise!
Posts 34 · Viewed 10682 · Go to Last Post
Saajha
· Snapshot
Like · Likedby · 0
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?

~@~
Load Previous
babali
· Snapshot
Like · Liked by · 0
sorry ppl i didn't mean to post same reply three times, somehow it came up
Saajha
· Snapshot
Like · Liked by · 0
@sangfroid, ln doesn't work. Creating a sym link and pointing it to /local/lib* is a great idea though!
About sftp and cp, as I mentioned earlier -- there's no need to pull libraries from the other machines - as they already are there, just one directory level below; and since cp/scp/mv don't work, there's no way I can copy those files. I can go into /local and see all lib* files by doing echo* -- just cannot move them, or point to them as you suggested!

@instinkt, thnx for your advice - but there are no backups!

@whois, thnx for your initiative as well! I'm trying every possibilities I can think of. Just emailed some opensource communities to see if they have a say for it. Won't be worth spending too much of time on this though ---

~@~
whois
· Snapshot
Like · Liked by · 0
As Sun4u said ,We also need to have better communtiy!!!!
I can see so many people in this field here!!!
Saajha
· Snapshot
Like · Liked by · 0
Ok, mirrored disk .. hmm..!! What difference would it make if you boot from the mirrored disk? Wouldn't that have a mirror copy of settings and configurations on it as well?
sangfroid
· Snapshot
Like · Liked by · 0
seeking help from auto mirrored disk is of no use......

this is its main drawback.... corrupted data also gets copied ....
Saajha
· Snapshot
Like · Liked by · 0
That's exactly what I thought !!!
babali
· Snapshot
Like · Liked by · 0

the only way i can think of is to access the machine physically and boot it off of cd and fix it !

Saajha
· Snapshot
Like · Liked by · 0
I agree with you @babali, that's always an option --- but if there was a way to somehow inject those files into it, that would be magnificent!!
oldmaven
· Snapshot
Like · Liked by · 0
.

I just wanted to say You're doomed buddy ;)

The first solution that comes to my mind would be: Boot it from a LIVE CD or sth, mount it, do the necessary copying, and voila!

THE other play that i would possibly do is: (not sure if it will work)

Find any source files (copying scripts) installed that didnot have dependency on /lib folders. (scp, sftp, rsync, copywhendisaster) - very dim chance. Or else, if there's anyway you can compile scripts , run gcc for that matter, use cp.c in coreutils/src to generate a binary (on that machine or a dift one) to move files back. I bet all of these would just be FOR FUN.

I would suggest you, if you cant anyhow follow the first option, start again. Accidents Happen ;)
oldmaven
· Snapshot
Like · Liked by · 0
.

And whats the mailing list / forum that you posted this on ? I'd like to keep an eye to think of any other options too.
Katmandude
· Snapshot
Like · Liked by · 0
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
· Snapshot
Like · Liked by · 0
.

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
· Snapshot
Like · Liked by · 0
You are right Oldmaven...rebuild.
Brain Malfunction
· Snapshot
Like · Liked by · 0

 

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
· Snapshot
Like · Liked by · 0
@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
· Snapshot
Like · Liked by · 0
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
· Snapshot
Like · Liked by · 0
.

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
· Snapshot
Like · Liked by · 0

@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/3617119/deb347c/POC.html

@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
· Snapshot
Like · Liked by · 0
.

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
· Snapshot
Like · Liked by · 0

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!!

~@~ 

Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 9 · Viewed 12601 · Likes 1
· Posts 7 · Viewed 4026 · Likes 1
· Posts 1 · Viewed 1096
· Posts 1 · Viewed 1089
· Posts 1 · Viewed 995
· Posts 1 · Viewed 1083
· Posts 1 · Viewed 1054
· Posts 21 · Viewed 10088 · Likes 1
· Posts 3 · Viewed 2615
· Posts 5 · Viewed 7814 · Likes 1



Your Banner Here
Travel Partners
Travel House Nepal