Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
9 years ago
I deleted a critical symbolic link -
libc.so.6. I have the file it should point at, but the basic commands such as
wget won't work anymore due to the link missing. However,
echo or other Bash builtins work.
I am looking for a way to recreate this symbolic link.
311 6 6 silver badges 18 18 bronze badges
May 10, 2014 at 18:05
535 1 1 gold badge 8 8 silver badges 18 18 bronze badges
you can use ldconfig, it recreates the symlink:
# rm /lib/libc.so.6
rm: remove symbolic link `/lib/libc.so.6'? y
# ls -l /lib/libc*
ls: error while loading shared libraries: libc.so.6: cannot open shared object file:
# ls -l /lib/libc*
lrwxrwxrwx. 1 root root 12 May 11 07:59 /lib/libc.so.6 -> libc-2.12.so
just tested it, as you see.
248 4 4 silver badges 17 17 bronze badges
May 11, 2014 at 6:02
natxo asenjo natxo asenjo
5,729 2 2 gold badges 26 26 silver badges 27 27 bronze badges
CentOS 6 generally comes with
, a statically-linked set of Unix tools, installed in
/sbin. You can run it like this:
/sbin/busybox ln -s libc-2.12.so /lib/libc.so.6
May 10, 2014 at 22:30
Set LD_PRELOAD to preload the relevant library. I tried it out with libpthread and it seems to work:
root@spirit:~# mv /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libpthread.so.0-bak
chattr: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
root@spirit:~# LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0-bak chattr
Usage: chattr [-RVf] [-+=AaCcDdeijsSu] [-v version] files...
May 10, 2014 at 19:32
Dennis Kaarsemaker Dennis Kaarsemaker
19.2k 2 2 gold badges 44 44 silver badges 70 70 bronze badges
sln serves exactly that purpose: to fix symbolic links when you can't use regular ln because you broke an essential symlink. To quote its man page:
The sln program creates symbolic links. Unlike the ln(1) program, it
is statically linked. This means that if for some reason the dynamic
linker is not working, sln can be used to make symbolic links to
231 3 3 silver badges 9 9 bronze badges
May 12, 2014 at 11:15
231 1 1 silver badge 2 2 bronze badges
You can set
LD_LIBRARY_PATH variable to include the directory where real
ldconfig for it to recreate the links. This should make the commands work so you can then use
ln commands to fix your system.
Another way would be to boot via LiveCD and link file there.
May 10, 2014 at 18:12
2,093 4 4 gold badges 19 19 silver badges 23 23 bronze badges
Use scp or sftp to copy a statically linked version of ln. Make sure it is executable. Then use it to fix the file.
May 11, 2014 at 21:27
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only
catis disabled... actually everything was.
catis an external program. The Bash Builtin Commands manual page has details about what could be available.