how to enable Selinux

Posted on 2014-09-11
Medium Priority
Last Modified: 2014-09-11
I try to enable Selinux from this site,http://wiki.eri.ucsb.edu/sysadm/SELinux , 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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 23

Assisted Solution

savone earned 400 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
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!


Assisted Solution

exploitedj earned 1600 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 1600 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

762 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