Permissions and owners

The setenforce command

Switches SELinux between Enforcing and Permissive on the fly, without a reboot.

Syntax

sudo setenforce 0|1Try it in the terminal →

Most useful options

1 | EnforcingPuts SELinux in Enforcing mode: blocks what the policy does not allow
0 | PermissivePuts SELinux in Permissive mode: only logs the denials

Copy-ready examples

$ getenforcechecks the mode before changing anything.

Example output

Enforcing
$ sudo setenforce 0switches to Permissive. Denials are still logged, but not enforced.
$ sudo setenforce Permissivethe same with the word: the program ignores letter case.
$ sudo setenforce 1switches back to Enforcing.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
setenforce: SELinux is disabledSELinux is not active on this system, so there is no mode to change.Check with getenforce. According to selinux(8), /etc/selinux/config decides whether SELinux is active.
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]A value other than these four was passed, or more than one argument.Use just one: Enforcing, Permissive, 1 or 0.

Typical mistakes

  • setenforce 0 is not permanent: the mode used at boot is set by SELINUX= in /etc/selinux/config, according to selinux(8).
  • Switching to Permissive to get rid of a denial hides the real problem: the warnings still go to the log. Fix the rule and go back to Enforcing.
  • If SELinux is disabled, setenforce answers with an error. Check with getenforce first.

Differences from similar commands

  • getenforce: shows the mode without changing it.
  • semanage: changes the stored policy: port, label and boolean rules. setenforce only decides whether it is enforced or logged.

FAQ

Does setenforce 0 disable SELinux?

Not really. It switches to Permissive, where denials are only logged. To disable it, selinux(8) recommends the selinux=0 boot parameter.

How do I keep it in Enforcing permanently?

Set SELINUX=enforcing in /etc/selinux/config, according to selinux(8), and check with getenforce after the next boot.

Can I write the word in lowercase?

Yes. The program compares without regard to case, so enforcing and Enforcing both work; it also accepts 1 and 0.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course