HowTo: Temporarily Switch Off SELinux Enforcement

Posted on in Categories last updated November 10, 2012

How do I temporarily switch off SELinux enforcement under Red Hat Enterprise Linux server version 6.x using command prompt? How do I turn on SELinux enforcement again?

SELinux can be run in any one of the following mode at any given time:

  1. enforcing : SELinux security policy is enforced.
  2. permissive : SELinux prints warnings instead of enforcing.
  3. disabled : SELinux is fully disabled.

You can use /selinux/enforce file to temporarily switch off SELinux enforcement on or off (i.e. set in permissive mode) using the following syntax.

Temporarily switch off SELinux enforcement

Type the following command as root user:
# echo 0 >/selinux/enforce
Type the following command to see current status, enter:
# sestatus
Sample outputs:

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

Temporarily switch on SELinux enforcement

Type the following command as root user:
# echo 1 >/selinux/enforce
Type the following command to see current status, enter:
# sestatus
Sample outputs:

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 1 comments/add one below):

1 comment

Leave a Comment