09.关闭或开启SeLinux+SeLinux三种状态

关闭或开启SeLinux及SeLinux的三种状态

临时关闭selinux

查看selinux

[root@localhost ~]# getenforce

Enforcing

 

关闭selinux

[root@localhost ~]# setenforce 0

 

查看selinux

[root@localhost ~]# getenforce

Permissive

 

永久关闭selinux

[root@bogon ~]# vim /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 three two values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

 

将SELINUX=enforcing修改为SELINUX=disabled

然后重启reboot服务器即可生效。

开启SELINUX

永久开启selinux

[root@bogon ~]# vim /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 three two values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

 

将SELINUX=disabled修改为SELINUX=enforcing或permissive

然后重启reboot服务器即可生效。

 

selinux的三种模式

Disable工作模式(关闭模式)

在 Disable 模式中,SELinux 被关闭,默认的 DAC 访问控制方式被使用。对于那些不需要增强安全性的环境来说,该模式是非常有用的。

 

Permissive工作模式(宽容模式)

在 Permissive 模式中,SELinux 被启用,但安全策略规则并没有被强制执行。当安全策略规则应该拒绝访问时,访问仍然被允许。然而,此时会向日志文件发送一条消息,表示该访问应该被拒绝。

 

Enforcing工作模式(强制模式)

从此模式的名称就可以看出,在 Enforcing 模式中, SELinux 被启动,并强制执行所有的安全策略规则。

posted @ 2020-12-23 10:26  AI非AI  阅读(325)  评论(0)    收藏  举报