Solved

Please help I screwed up my linux box!

Posted on 2004-04-21
13
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

688 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