Turn on SELinux in Redhat or CentOS Linux Over Remote SSH Session

by on February 15, 2010 · 5 comments· LAST UPDATED February 15, 2010


My hosting company disabled SELinux protection. How do I turn on SELinux over remote ssh session without distributing existing networking services?

You can enable SELinux it by typing the following commands:
# touch /.autorelabel
# reboot

After reboot turn it on:
# setenforce 1
You need to modify /etc/grub.conf or /etc/selinux/config to enable SELinux after each reboot. Edit /etc/selinux/config, enter:
# vi /etc/selinux/config
Edit/add as follows:


See also:

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 5 comments… read them below or add one }

1 od February 16, 2010 at 11:51 am

Another way is by running system-config-securitylevel-tui.


2 Michael February 18, 2010 at 7:02 pm

The question in the article was:
How do I turn on SELinux over remote ssh session without distributing existing networking services?

Pay attention to the last part: “without distributing existing networking services”

Then as a solution is posted:
# touch /.autorelabel
# reboot

Yes I have read i correct. The last command is reboot….
hmm . reboot without “distributing existing networking services”

Nice article by the way…


3 nixCraft February 18, 2010 at 8:09 pm


Without reboot you cannot activate SELinux. However, if you do not follow these instructions many files and services such as ssh will not activate after the reboot. In that case you need to login over console and fix the issue. So once system comes online you run the ‘setenforce 1′ command to turn it on. Nevertheless, you cannot get it activated without rebooting the system. May be you need to use ksplice [ksplice.com] service based patch which allows:

you apply 100% of the important kernel security updates released by your Linux vendor without rebooting.

I never tried it out, but this may be the solution…



4 Michael February 18, 2010 at 8:15 pm

ok. got it! Thanks….

(at this moment I have another weird situation: The CAPS lock function of my keyboard is reversed :-)… When the LED on the keyboard is ON the letters appear in lower case and visa versa… I Googled a bit but found not yet a simple solution yet… (distrubution=Fedora 12))

Keep up the good work.


5 Dhan August 13, 2012 at 4:05 pm

Hi Guys,

Im using VPS with kloxo panel.
SELinux status: disabled

I tried to edit config file as well

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
# mls – Multi Level Security protection.
# SETLOCALDEFS= Check local definition changes

rebooting successful but still it doesn’t work,

setenforce 1
setenforce: SELinux is disabled

many Thanks


Leave a Comment

Tagged as: , , , , , , , ,

Previous Faq:

Next Faq: