How to Disabled SELinux using Command Line on CentOS 6/RHEL 6

Share this Article :

In this short article, I’ll show you an easy way to disable SELinux in RHEL or CentOS 6 6. You only need to run the following command line. After that, make sure you reboot your CentOS server for changes to take effect.

1. Verify the SELINUX setting before changes :

[[email protected] ~]# sestatus
SELinux status:                 enforcing

Check the config file :

[[email protected] ~]# cat /etc/sysconfig/selinux
..
..
SELINUX=enforcing
..
..

2. Issue the following command to changes the config file :

[[email protected] ~]# sed -i 's/(^SELINUX=).*/SELINUX=disabled/' /etc/sysconfig/selinux

3. Verify the SELINUX status again :

[[email protected] ~]# sestatus
SELinux status:                 disabled

Check the config file again :

[[email protected] ~]# cat /etc/sysconfig/selinux

It will change the following, SELINUX=disabled

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

4. Reboot the CentOS/RHEL server :

[[email protected] ~]# reboot

Leave a Reply