Solved

Please help I screwed up my linux box!

Posted on 2004-04-21
13
227 Views
Last Modified: 2010-04-20
Hello, I was trying to temporarily clear up some space on my root filesystem and temporarily did a:

cd /lib
mv * ~greg/lib_backup

Now none of my commands don't work, I can't connect via ssh, and only have 1 ssh session still active...

what do I do???
0
Comment
Question by:fozzynet
  • 3
  • 2
  • 2
  • +4
13 Comments
 

Author Comment

by:fozzynet
ID: 10881208
[root@alpha lib]# cd ~greg/lib_backup
[root@alpha lib_backup]# mv * /lib
bash: /bin/mv: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
0
 
LVL 6

Expert Comment

by:karlwilbur
ID: 10881509
I don't know off the top of my head which command are going to work and which are not.  

You could try to cp each file that can't be found one at a time until you can mv all of them back.

cp ~greg/lib_backup/ld-linux.so.2 /lib/ld-linux.so.2

cp ~greg/lib_backup/* /lib

or

ln -s ~greg/lib_backup/ld-linux.so.2 /lib

cp ~greg/lib_backup/* /lib


If you have phisical access to the Linux box and can reboot, you could use something like KNOPPIX to boot then mount your harddrive and cp everything back that way.

-Karl
0
 
LVL 40

Expert Comment

by:jlevie
ID: 10882477
The only way you are going to fix this is to boot from CD in rescue mode, or a mini-linux like Knoppix, tomsrtbt. SuperRescue, etc. and undo the mv of the shared libs.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10883377
I second jlevie's approach. The problem you'll have is to figure out what belongs into /lib and what should stay in ~/lib_backup (if anything).
Depending on which Linux distribution you are using, you may be able to use your first installation CD to boot into rescue mode. This will be a separate Linux system, that has nothing to do with your installed system. You need to first mount the partition(s) that your system uses. Here is a made up example:

Once you are in rescue mode, do this (and replace the partitions and paths with the correct ones for your system):

mkdir /mnt
mount /dev/hda1 /mnt
mount /dev/hda2 /mnt/home

After you do this, your original / disk will now be available as /mnt, and your /home partition (if you used one) will be available as /mnt/home. This means that your original directory ~greg is now /mnt/home/greg
(or something similar, depending on how your system is set up). Now you can move the files from /mnt/home/greg/lib_backup to /mnt/lib
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10884290
One thing you could try is the following :

export LD_LIBRARY_PATH=~greg/lib_backup (replacing the ~greg by the real path like /home/greg).

You might have a chance that the dynamic linker recognizes the new file paths and allows you to use at least the mv command
to move your files back.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10884597
In the old days :-) SunOS had two versions of important commands like mv, cp, rm: One dynamically linked in /usr/bin, and one statically linked in /sbin. This way, you were always able to run these commands, even with a hosed library directory. You can still create statically linked binaries, but AFAIK no distribution ships them linked this way.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 8

Expert Comment

by:da99rmd
ID: 10886449
I will make the old days come back right now, compiling a statically linked for me.

/Rob
0
 

Author Comment

by:fozzynet
ID: 10888873
I got some help from a linux guru on mirc, I issued these commands and was able to fix it.

cd ~greg/lib_backup
./ld-2.3.2.so /bin/cp -ar . /lib/

Worked great...
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10889046
Oh. I love it ! Pretty elegant. Did you try my LD_LIBRARY_PATH trick ? I wonder if it woud work (it should).
0
 

Author Comment

by:fozzynet
ID: 10889116
I did try that at first as the guy in mirc told me try that as well. It didn't seem to work unfortunately.
0
 
LVL 6

Expert Comment

by:karlwilbur
ID: 10890430
Sweet. That's great.

I thought that cp would have worked but I was not quite sure how to go about it with out ld-2.3.2.so in /lib. Now I know too. Thanks.

I use LFS and keep a set of statically linked tools in /sbin/tools as khkremer mentioned.  You know, just in case. I been know to do reeeealy stupid things sometimes. :-)  But I had to place these there myself; it's not part of the instructions.

-Karl
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 16143325
PAQed with points (250) refunded

DarthMod
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now