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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. “systemd-udevd: Cannot Allocate Memory” and “A start job is running for dev-mapper-\x2droot.device” – CentOS/RHEL 7 booting issue
  2. fc-cache: Scan font directories to build font cache files
  3. mdadm: Cannot open /dev/sda1: Device or resource busy
  4. CentOS / RHEL 6 : How to change SNMP log level
  5. How to resize (extend) a partition-based file system in Linux
  6. kpartx Command Examples in Linux
  7. CentOS / RHEL : How to remove unused Physical Volume(PV) from Volume Group (VG) in LVM
  8. ldd: command not found
  9. Linux OS Service ‘xendomains’
  10. kjv Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “glab issue” Command Examples
  • “glab auth” Command Examples
  • “glab alias” Command Examples
  • gixy Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright