• 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

How to Check whether SELinux is Enabled or Disabled

by admin

Question : How to Check whether SELinux is Enabled or Disabled

Answer :
SELinux gives that extra layer of security to the resources in the system. It provides the MAC (mandatory access control) as contrary to the DAC (Discretionary access control). Before we dive into setting the SELinux modes, let us see what are the different SELinux modes of operation and how do they work. SELinux can operate in any of the 3 modes :

1. Enforced : Actions contrary to the policy are blocked and a corresponding event is logged in the audit log.
2. Permissive : Permissive mode loads the SELinux software, but doesn’t enforce the rules, only logging is performed.
3. Disabled : The SELinux is disabled entirely.

Check the SELinux status

use this command to check current status:

# getenforce
Permissive

The output will be either of the 3 options described above. For more verbose (in the case of permissive), use:

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

To programmatically check the status as a true/false, one way could be:

# selinuxenabled
if [ $? -ne 0 ]
then 
    echo "DISABLED"
else
    echo "ENABLED"
fi

This will return ENABLED or DISABLED.

How to Disable or set SELinux to Permissive mode

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to enable IPv6 on CentOS / RHEL 6
  2. How to grep with color output
  3. postfix Command Examples in Linux
  4. “polkit code=exited status=1/FAILURE” – PolicyKit Failing to Start in CentOS/RHEL 7 and 8
  5. CentOS / RHEL 5,6 : How to reinstall GRUB loader from rescue mode
  6. foreman Command Examples in Linux
  7. pinky Command Examples in Linux
  8. Linux rsync command with practical examples
  9. sysctl setting for high load and prevent DDoS
  10. How to Configure Network Teaming in CentOS/RHEL 7

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