centos6报错ls: error while loading shared libraries: libc.so.6: cannot open shared object file

时间:2023-02-01 12:57:33

生产环境由于误删了libc-2.12.so和libc.so.6文件导致报错如下:

centos6报错ls: error while loading shared libraries: libc.so.6: cannot open shared object file

现在复现此过程:

1.移除这2个文件

mv libc-2.12.so libc.so.6  /opt/

此时再次执行命令就会报错,错误信息如下:

ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

2.解决办法

(1).设置环境变量
export LD_PRELOAD="/opt/libc-2.12.so"
(2).然后把库给链接回来
ln -s /opt/libc-2.12.so /lib64/libc.so.6

centos6报错ls: error while loading shared libraries: libc.so.6: cannot open shared object file

此时再次执行命令就可以正常操作了

centos6报错ls: error while loading shared libraries: libc.so.6: cannot open shared object file