centos6.5查看SELinux状态及关闭

1.查看selinux的状态

  • getenforce 命令是单词get(获取)和enforce(执行)连写,可查看selinux状态,与setenforce命令相反
  • setenforce 命令则是单词set(设置)和enforce(执行)连写,用于设置selinux防火墙状态,如: setenforce 0用于关闭selinux防火墙,但重启后失效
[root@localhost ~]# getenforce
Enforcing

sestatus:
查看当前系统上面SELinux的策略,运行模式等信息

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

SELinux status:selinux防火墙的状态,enabled表示启用selinux防火墙
Current mode: selinux防火墙当前的安全策略,enforcing 表示强

2.关闭SElinux

2.1 临时关闭(不用重启即可生效)

setenforce 0 :用于关闭selinux防火墙,但重启后失效
[root@localhost ~]# setenforce 0

[root@localhost ~]# 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:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

setenforce 0 ##设置SELinux 成为permissive模式

2.2 SElinux的三种模式

  • enforcing:强制模式:代表 SELinux 运作中,且已经正确的开始限制 domain/type 了
  • permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制
  • disabled:关闭:SELinux 并没有实际运作

2.3 永久关闭SELinux(需重启生效)

打开selinux配置文件
[root@localhost ~]# vim /etc/selinux/config
将SELINUX=enforcing改为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=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

重启
root@localhost ~]# reboot

验证状态

[root@localhost ~]# /usr/sbin/sestatus
SELinux status:                 disabled
 
[root@localhost ~]# getenforce
Disabled

至此 selinux关闭完成

    原文作者:yulate
    原文地址: https://blog.csdn.net/weixin_43976137/article/details/100633062
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞