SELinux系列(五)——SELinux工作模式设置(getenforce、setenforce和sestatus命令)
发布日期:2021-06-30 17:45:50 浏览次数:2 分类:技术文章

本文共 932 字,大约阅读时间需要 3 分钟。

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

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

[root@localhost ~]# getenforce#查询SELinux的运行模式Enforcing#当前的SELinux是强制模式[root@localhost ~]# sestatusSELinux status:              enabledSELinuxfs mount:             /selinuxCurrent mode:                enforcingMode from config file:       enforcingPolicy version:              24Policy 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 ~]# getenforcePermissive[root@localhost ~]# setenforce 1#切换成强制模式[root@localhost ~]# getenforceEnforcing

转载地址:https://lexsaints.blog.csdn.net/article/details/107843257 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:SELinux系列(六)——SELinux安全上下文查看方法 详细介绍
下一篇:SELinux系列(四)——SELinux配置文件(/etc/selinux/config)详解

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月28日 22时54分09秒