Solved

Please help I screwed up my linux box!

Posted on 2004-04-21
13
239 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

809 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