False alarm after mistakenly deleting libc.so.6
1. libc.so.6 Introduction
/usr/lib/libc.so.6 is a soft link to glibc, and the path may be different for different platforms.
Use the command to see:
[root@farmer:~]$ls -l /lib/libc.so.6
lrwxrwxrwx 1 root root 11 Jan 1 22:23 /lib/libc.so.6 -> libc-2.9.so
Glibc is gnu's libc library, the c runtime. Glibc is the lowest api in linux. Almost any other runtime depends on glibc, so most commands don't lack it.
2. error deletion processing
How to delete libc.so.6 by mistake, most system commands will not be executed, ssh login system will not succeed, only the following errors will be endlessly prompted:
error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
In this case, most commands cannot be executed, only a small number of commands such as cd,echo, etc. can be executed, and the practical cp,mv are not available.
After all kinds of Baidu, get the solution (and the premise of this method is that ssh has not been disconnected, if ssh has been disconnected, it cannot be reconnected, you have to use another method to restart with CD to enter emergency mode):
In the same version of the system to see/lib/libc.so.6 is a soft link belonging to libc-2.9.so, therefore, libc-2.9.so file must still exist, mistakenly deleted only soft links, but at this time want to use ln command to re-establish soft links is a failure, but you can force the variable can be executed successfully!
LD_PRELOAD=/lib/libc-2.9.so ln -s /lib/libc-2.9.so /lib/libc.so.6
The red part is the temporary library specified by glibc, so libc.so.6 is restored correctly after proper execution.
3. subsequent
Glibc is a very low-level library, bash also depends on her, so if you kill this library, basically nothing can be done, but why set the LD_PRELOAD variable in front of it? LD_PRELOAD can affect the runtime linker of the program. It allows you to define dynamic link libraries that are loaded first before the program runs. Before libc.so.6, the soft link is killed, so the system cannot find this library. However, by setting the real address of glibc library by LD_PRELOAD, this problem can be solved.