I booted into a Rocky Linux 9.4 USB and entered Rescue Environment. I press option 1 and then saw a message;
“Your system has been mounted under /mnt/sysroot.
If you would like to make the root of your system the root of the active system, run the command:
chroot /mnt/sysroot”
I access system by running the command chroot /mnt/sysroot
To disable SELinux temporarily: setenforce 0
To revert the SELinux configuration: nano /etc/selinux/config
I changed the line to targeted
sudo reboot
It tried to boot but ran into an issue where it needed to autorelabel something
Next time you can try to press e while in the boot menu and add the following parameter selinux=0. It should disable selinux for the current boot only.
If this should not work, you can add the kernel parameter init=/bin/bash to spawn a shell, instead of booting the whole system.
If you use this rescue methods to change files, you need to create an empty file called .autorelabel within the / directory for selinux to appropriately label the files you have changed.