首页 > 代码库 > selinux详解

selinux详解

查看selinux配置文件

[root@localhost ~]# cat  /etc/selinux/config

# 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=enforcing

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

修改selinux为关闭状态


方法一

[root@localhost ~]# vi /etc/selinux/config

# 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

在vi下按“i”进行编辑,讲enforcing改为disabled

按“esc”退出编辑模式,“:wq ” 保存退出



检查:cat /etc/selinux/config



方法二

设置:sed -i s#SELINUX=enforcing#SElINUX=disabled#g /etc/selinux/config

检查:grep "disable" /etc/selinux/config


以上永久关闭selinux,重启生效




查看selinux状态:

[root@localhost ~]# getenforce 

Enforcing

临时关

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce 

Permissive

即时生效



selinux详解