0

So I have a CentOS VM and changed SELinux to enforcing (which was a mistake), and after rebooting I couldn't login at all (even with root - there was a login loop where I kept getting sent back to the logins screen). I have a VM snapshot I can revert to, but that would mean undoing all the changes I've made (which is a last resort).

I've confirmed that changing SELinux to enforcing is the issue, but is there anyway to change sestatus without logging in?

1
  • I'm sure you've heard that before, but I will repeat it mostly for future readers coming through. It's 2022, there's barely a reason to operate a system without SELinux enforced. If you can't log in with SELinux enabled, it's likely you've somehow for broken labeling for e.g. your home directory, and it would be wiser to fix that than to disable this crucial security feature. That being said, maybe this is an experimental/security research VM and it being less secure than possible is the whole point. In that case, of course, d disregard this comment altogether. Jul 23, 2022 at 9:02

1 Answer 1

0

If you haven't changed the default grub configuration, you should be able to boot into single user mode.

At the grub boot menu, press "e" to edit the kernel arguments. In the linux line, change ro to rw and add init=/sysroot/bin/sh.

Press "Ctrl-x". You should boot into a root shell.

Your system should be mounted at /sysroot, so use the command chroot /sysroot before continuing.

Now you should be able to modify the SELinux policies as usual.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .