Solved

Please help I screwed up my linux box!

Posted on 2004-04-21
13
233 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

778 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