Linux中关闭SELinux的方法

[复制链接]
leda 发表于 2022-6-15 15:17:41 | 显示全部楼层 |阅读模式
本帖最后由 leda 于 2022-6-15 16:30 编辑

Linux中关闭SELinux的方法

1、临时关闭:输入命令setenforce 0,重启系统后还会开启。

2、永久关闭:输入命令vi /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,然后保存退出。




------------------------------------------------------------------------------------------------------------------------------------------
SELinux工作模式设置(getenforce、setenforce和sestatus命令)

除了通过配置文件可以对 SELinux 进行工作模式的修改之外,还可以使用命令查看和修改 SELinux 工作模式。

首先,查看系统当前 SELinux 的工作模式,可以使用 getenforce 命令;而如果想要查看配置文件中的当前模式和模式设置,可以使用 sestatus 命令,下面的代码显示了这两个命令:

[root@localhost ~]# getenforce
#查询SELinux的运行模式
Enforcing
#当前的SELinux是强制模式
[root@localhost ~]# sestatus
SELinux status:              enabled
SELinuxfs mount:             /selinux
Current mode:                enforcing
Mode from config file:       enforcing
Policy version:              24
Policy from config file:     targeted

除可以查询 SELinux 的运行模式之外,也可以修改 SELinux 的运行模式,即使用 setenforce 命令。不过需要注意,setenforce 命令只能让 SELinux 在 enforcing 和 permissive 两种模式之间进行切换。如果从启动切换到关闭,或从关闭切换到启动,则只能修改配置文件,setenforce 命令就无能为力了。

setenforce 命令的基本格式如下:

[root@localhost ~]# setenforce 选项
选项:

    0: 切换成 permissive(宽容模式);
    1: 切换成 enforcing(强制模式);


例如:
[root@localhost ~]# setenforce 0
#切换成宽容模式
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# setenforce 1
#切换成强制模式
[root@localhost ~]# getenforce
Enforcing


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|RuZhuo ( 鄂ICP备16015978号-8 )

GMT+8, 2024-5-16 11:46 , Processed in 0.028126 second(s), 28 queries .

Powered by RuZhuo

快速回复 返回顶部 返回列表