Setenforce SELinux is Disabled
Question
I Have a Linux Web Server, which has CentOS 7 Installed. Now I am trying to use setenforce command to change selinux mode between permissive mode and enforcing mode. But I Only get Following Error “setenforce: SELinux is disabled”.
Can Someone tell me, What I am doing Wrong and How to Fix This Error.
Answer
You get this Error “setenforce selinux is disabled” because you have permanently disable selinux in your CentOS7 server. we can verify this by using sestatus command.
sestatus
setenforce command has no effect if you have selinux disabled permanently in the main configuration file.To enable selinux open /etc/sysconfig/selinux file with a text editor.
vim /etc/sysconfig/selinux
now set SELinux security policy value to enforced
SELINUX=enforcing
Now You Need to Restart The Server in order to change to be effective. (You Do Not Want to Restart your server when switching between Enforcing and Permissive modes using setenforce command when selinux enabled in the main configuration file).