how to enable Selinux

Posted on 2014-09-11
Last Modified: 2014-09-11
I try to enable Selinux from this site, , but it didn't work, On linux shell, I tried this command as follows

root@vps# getenforce


root@vps#setenforece 1

setenforce: SELinux is disabled

root@vps# getenforce


change the file at /etc/sysconfig/selinux from changing SELINUX=enforcing to SELINUX=disabled

reboot, but it didn't work.

On the link instruction, why turn on Selinux need to SELINUX=disabled ?
And how I know selinux is enabled or not ?

Please advise
Question by:rwniceing
  • 4
  • 2
LVL 23

Assisted Solution

savone earned 100 total points
ID: 40318167
Edit  /etc/selinux/config and make sure it is enforcing.

The file should look like this when done:
# 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 - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.

Reboot the system to load selinux.

Author Comment

ID: 40318175
Yes  I did,

but when getenforce it still echo


I talk to my hosting company said
We use OpenVZ virtualization (most popular VPS virtualization system), which doesn't support selinux for security reasons, i am sorry, but we have no option to enable it.

Is the main reason from the hosting company statement that is why
always get "Disabled" from getenforce ?

Author Comment

ID: 40318180
Whatever I try, I always get this

root@vps#setenforece 1

setenforce: SELinux is disabled
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.


Assisted Solution

exploitedj earned 400 total points
ID: 40318215
Ok, the first thing to check is what does sestatus return for the "SELinux status: "

If that line returns disabled that means that you disabled it before a reboot. Think of this like the main breaker on your house. If it is off, the circuit breakers between enforcing and permissive won't mean much.

If that is the case you can set your  /etc/sysconfig/selinux to "SELINUX=enforcing"  then reboot.
The sestatus "SELinux status: " should now return "enabled". Now you can use set enforce to switch between enforcing and permissive.

Permissive is different than Disabled. It is SUPER IMPORTANT to understand how "Disabling" impacts policies relabeling. This is not uncommon and can lead to many headaches. Fedora documentation does a good job describing this. As do Dan Walsh's blogs. He is pretty much "the Man" with SeLinux.

Note - This may not fall into this thread but you typically want to avoid Disabling in SeLinux, even when troubleshooting, as you can undo a lot of policy label changes if you didn't set them properly. Go with Permissive as you gain your footing and if you need to figure out if SElinux is messing something up.

Author Comment

ID: 40318219
savone and exploitedj thanks for your reply,  exploitedj ,command result as follows

root@vps [~]# sestatus
SELinux status:                 disabled

Please read this post

You agree hosting company has such ability ?

Accepted Solution

exploitedj earned 400 total points
ID: 40318240
I just commented there and came here to double check that the virtualization was with OpenVZ. Guess so since you are the question asker in both?

Author Closing Comment

ID: 40318255
Thanks for all of your reply

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question