SELinux 开启和关闭

发布时间:2025-05-08 03:19

检查开关是否正常工作,开启和关闭应无异常声音。 #生活知识# #家庭维修常识# #家庭电路检测#

最新推荐文章于 2025-03-28 09:05:34 发布

liguangxian2018 于 2018-08-13 13:56:52 发布

1. 查看SELinux状态

1.1 getenforce

getenforce 命令是单词get(获取)和enforce(执行)连写,可查看selinux状态,与setenforce命令相反。

setenforce 命令则是单词set(设置)和enforce(执行)连写,用于设置selinux防火墙状态,如: setenforce 0用于关闭selinux防火墙,但重启后失效

 

[root@localhost ~]# getenforce

Enforcing

1.2 /usr/sbin/sestatus

Current mode表示当前selinux防火墙的安全策略

 

[root@localhost ~]# /usr/sbin/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 ~]# /usr/sbin/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

2.1 永久关闭

修改selinux的配置文件,重启后生效。

打开 selinux 配置文件

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

修改 selinux 配置文件

将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

此时获取当前selinux防火墙的安全策略仍为Enforcing,配置文件并未生效。

 

[root@localhost ~]# getenforce

Enforcing

重启

[root@localhost ~]# reboot

验证

 

[root@localhost ~]# /usr/sbin/sestatus

SELinux status: disabled

 

[root@localhost ~]# getenforce

Disabled

转自: https://blog.csdn.net/GGxiaobai/article/details/53505095

网址:SELinux 开启和关闭 https://www.yuejiaxmz.com/news/view/940397

相关内容

selinux= 为 disabled
eco模式是开启好还是关闭好
开启或关闭智慧助手·今天(负一屏)
小米手机省电模式怎么关闭和打开
汽车后尾灯的开启和关闭方法是怎样的?操作过程中如何避免损坏?
华为鸿蒙系统如何开启智慧助手?鸿蒙系统开启或关闭智慧助手的方法
松下空调自清洁功能详解,开启与关闭操作指南
空调eco能省多少电,空调eco模式是开启好还是关闭好
智慧生活App不能远程关闭或开启华为智慧屏
win10系统驱动人生的开机启动项drivethelife.exe怎么关闭?金山毒霸提供解决方案

随便看看