• 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. How to Enable FTP in CentOS/RHEL 5 and 6
  2. Adding Static Routes On Various *NIX (Linux,AIX,HP-UX)
  3. How to restore files under user’s home directory to default in Linux
  4. How to Boot into Rescue Mode or Emergency Mode Through Systemd in CentOS/RHEL 7 and 8
  5. Understanding the nfsiostat command output (Examples Included)
  6. What is the purpose of “mysql.sys@localhost” user
  7. jobs Command Options In Linux
  8. lvremove Command Examples in Linux
  9. How to make CentOS/RHEL 7 FIPS 140-2 compliant
  10. CentOS / RHEL : How to log all LVM commands

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright