• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

setenforce Command Examples in Linux

by admin

We can change the SELinux modes from enforcing to permissive and vice versa during runtime by using the setenforce command. Before and after changing the SELinux mode, we must ensure the current mode by using the getenforce command.

SELinux can either be in an enabled or a disabled state. In order to check in which state it is running, we can make use of the getenforce command. There are two modes in which SELinux runs:

  • Enforcing: This is the enabled state where all rules are applied.
  • Permissive: In this state, SELinux will not deny any access; however, denials are logged.

setenforce Command Examples

1. To modify the SELinux mode to Enforcing:

# setenforce Enforcing
# setenforce 1 

2. To modify the SELinux mode to Enforcing:

# setenforce Permissive
# setenforce 0 

3. To see the help:

# setenforce --help 

4. To display the current SELinux mode, use the following command:

# getenforce

5. To view detailed SELinux information, use the following command:

# sestatus

Conclusion

We can easily switch states between enforcing and permissive with the help of the setenforce command. To change to a permissive state, we use the setenforce 0 command, and to switch back to enforcing, we use the setenforce 1 command. However, the changes will not persist through reboots. In such a case, we can directly edit the configuration file located at /etc/selinux/config.

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. lspci Command Examples in Linux
  2. How to make ethtool settings persistent across reboots in CentOS / RHEL 6,7
  3. How to Delete unnecessary Entry in /etc/shadow
  4. Unable to set a GRUB password on a Raspberry Pi 3 system
  5. tar Command Examples in Linux
  6. MySQL Fails to Start Using systemctl On systemd Linux Distributions
  7. Linux “shutdown”, “poweroff”, “halt”, “reboot” Commands
  8. How to create an XFS Filesystem
  9. CentOS / RHEL 7 : Enable NTP to start at boot after fresh install (disable chrony)
  10. Swapon Fails To Mount Swap – Gives Invalid Argument Error

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright