Accidentally deleted symlink libc.so.6 in CentOS 6.4. How to get sudo privilege to re-create it?
The best thing to do in this case by far is to boot the server using a livecd, mount the applicable partitions, and create the symlink (be careful that the symlink points to exactly the right place when doing this, as if it points to a different absolute path than when you are running, it will not be helpful).
I can't think of a program you can run which will not require libc, nor a way to modify root's environment without root (by design the latter is impossible).
Also, you should really unbind the macro key which has sudo rm /lib64/libc.so.6
, enter, your password, and enter bound to it. I can think of only a few more inconvenient accidental keypresses.
However, as a last ditch attempt, try using su
with no options, which preserves most of your environment and sets your UID to root.
You may also be able to create the symlink in the current working directory and run things, though this doesn't always work.
Related videos on Youtube
kangshiyin
Updated on September 18, 2022Comments
-
kangshiyin over 1 year
I accidentally deleted the symbol link /lib64/libc.so.6 -> /lib64/libc-2.12.so with
$ sudo rm libc.so.6
Then I can not use anything including
ls
command. The error appears for any command I typels: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
I've tried
$ export LD_PRELOAD=/lib64/libc-2.12.so
After this I can use
ls
andln ...
, but still can not usesudo ln ...
,sudo -E ln ...
,sudo su
or evensu
. I always get this errsudo: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
or
su: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
It seems
LD_PRELOAD
works only for the current shell session of my account, but not for a new account likeroot
or a new session.It's a remote server so I can not use a live CD. I now have a ssh bash session alive but can not establish new ones. I have sudo privilege, but don't have root password.
So currently my problem is I need to run
sudo sln -s libc-2.12.so libc.so.6
to re-create the symlinklibc.so.6
, but I can not runsudo
withoutlibc.so.6
.How can I fix it? Thanks~
-
ALex_hha almost 11 yearswhich version of kernel do you use?
-
kangshiyin almost 11 years@ALex_hha 2.6.32-358.6.2.el6.x86_64
-
ALex_hha almost 11 yearsUnfortunately, packetstormsecurity.com/files/121616/semtex.c will not work
-
-
kangshiyin almost 11 years
su
does not work either. It seems the only way is to wait until holiday ends and use the live cd. Thanks. -
Falcon Momot almost 11 yearsAdded one more thing I forgot about...
-
kangshiyin almost 11 yearsYes, I found
LD_PRELOAD
allow me to run most of the applications. but still can not compile c code. It seemsgcc
andld
need the orignal /lib64/libc.so.6 when compiling. -
Falcon Momot almost 11 yearsThey need it (or a symlink) when linking if the linker links in libc (it does). It also has to be in the linker's library search path (specify with -l).
-
kangshiyin almost 11 yearstried but failed. a lot of external dynamic libs and non-gcc compilers required by my code make things very complicated.
-
Falcon Momot almost 11 yearsYeah, do the livecd thing then.