Solved

Please help I screwed up my linux box!

Posted on 2004-04-21
13
222 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
Comment Utility
[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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

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

/Rob
0
 

Author Comment

by:fozzynet
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with points (250) refunded

DarthMod
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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 …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

772 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

15 Experts available now in Live!

Get 1:1 Help Now