Page 1 of 1

Accidentally removed libselinux and nothing works

Posted: 2018/06/13 14:13:12
by RajeshB61
I have accidentally removed libselinux on centos 7.4 and am unable to install it again and all commands fail. How do i recover?

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

yum install libselinux-2.5-12.el7.x86_64
There was a problem importing one of the Python modules required to run yum. The error leading to this problem was:

libselinux.so.1: cannot open shared object file: No such file or directory

yum or rpm commands also show the same error. I do have files as below.

[root@localhost lib64]# locate libselinux.
/usr/lib/tmpfiles.d/libselinux.conf
/usr/lib64/libselinux.so.1

But /usr/lib64/libselinux.so.1 seems to be empty. I cant do an ssh or scp oe wget to download the files.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/13 18:07:27
by pjsr2
When you are booting the computer, add option

Code: Select all

selinux=0
to the kernel command line. That'll disable selinux and all your programs should work again. Than you can reinstall the selinux library.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/13 18:12:45
by TrevorH
I don't think that will work if the programs are linked against it and it's missing. Your best bet is to boot the install DVD in rescue mode - it's an option off the troubleshooting menu - then copy the version of that file off the DVD onto your system, probably renaming the original first just in case. Once it boots then yum reinstall libselinux-2.5-12.el7.x86_64 to make sure everything is correct.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/13 19:47:36
by RajeshB61
Hi,

The machine has CentOS 7 image on it. We will try to see if a reboot can work.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/14 05:49:13
by desertcat
TrevorH wrote:
2018/06/13 18:12:45
I don't think that will work if the programs are linked against it and it's missing. Your best bet is to boot the install DVD in rescue mode - it's an option off the troubleshooting menu - then copy the version of that file off the DVD onto your system, probably renaming the original first just in case. Once it boots then yum reinstall libselinux-2.5-12.el7.x86_64 to make sure everything is correct.
... It also pays BIG time if you have a recent backup. I make two FULL DISK backups: one right after a point release happens and I have configured it the way I want, and the second just before the next point release comes out, just in case the next update blows up the computer. In between I am now making weekly backup of key directories and partition using Backupninja. Once you get the machine backup and running you might want to consider installing Backupninja and set it to automatically backup key files, directories, etc. at some frequency you like (I have mine set to weekly). Trust me it will save your butt should it ever need saving.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/14 10:57:53
by RajeshB61
Thanks for the response. We will explore it. However, a reboot couldn't solve it. So building it again from a similar server.

Re: Accidentally removed libselinux and nothing works

Posted: 2018/06/14 11:31:17
by TrevorH
I did say you need to boot the install DVD in rescue mode. Your current system is broken because of that missing file and you won't be able to do it from there.