I am using RHEL 6.5 and I need to enable SELinux. I have tried following commands, but it does not work:

$ setenforce 1
$ echo 1 > /selinux/enforce

Note: I also tried editing /etc/selinux/config, but there is no such file present.

Edit: #1

Output of sestatus is as follows:

LinuxBox root [scripts] > sestatus
SELinux status:                 disabled

Firstly search if selinux is installed.

rpm -qa | grep selinux, rpm -q policycoreutils, and rpm -qa | grep setroubleshoot

If this doesn't show anything then install selinux by,

sudo yum install selinux

After selinux is installed, configure SELINUX=permissive in /etc/selinux/config

Then finally restart your computer for selinux to take effect.

  • rpm -qa | grep setroubleshoot shows nothing, but other two packages are installed there. – Mandar Shinde Nov 4 '14 at 10:44
  • 1
    What happens when you re-install selinux? – Ruban Savvy Nov 4 '14 at 11:14

Given you're using RHEL, SELinux is likely already installed. To confirm:

$ rpm -aq | grep -i selinux

You'll see packages similar to the above. This is from F19, but should apply to your situation as well. You can also confirm using the setstatus command:

$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

There's a warning/note within this document if you're adding SELinux to a system that was initially setup without it.

If the system was initially installed without SELinux, particularly the selinux-policy package, which was added to the system later, one additional step is necessary to enable SELinux. To make sure SELinux is initialized during system startup, the dracut utility has to be run to put SELinux awareness into the initramfs file system. Failing to do so causes SELinux not to start during system startup.

When dealing with RHEL it's advisable to seek out the excellent manuals that Red Hat maintains for any RHEL release. SELinux is well documented and everything you need to know is covered there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.