18.5 SELinux工作模式设置

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

除了通过配置文件可以对 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
目录
相关文章
|
4月前
|
弹性计算 运维 Shell
关闭SELinux
【4月更文挑战第29天】
35 0
|
4月前
|
弹性计算 运维 Shell
关闭 SELinux
【4月更文挑战第29天】
28 0
|
Shell 网络安全 Perl
关闭系统防火墙和SELinux
关闭系统防火墙和SELinux
72 1
|
编解码 缓存 安全
18.3 SELinux 的3种工作模式
通过对 SELinux 的介绍,初学者可以这样认为,在传统 Linux 系统使用访问控制方式的基础上,附加使用 SELinux 可增强系统安全。 那么,SELinux 是如何运行的呢?
504 0
18.3 SELinux 的3种工作模式
SELinux 开启和关闭
查看SELinux状态: 1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态 SELinux status:                 enabled 2、getenforce                 ##也可以用这个命令检查 关闭SELinux: 1、临时关闭(不用重启机器): sete
1522 0
|
Linux 网络安全
Linux防火墙该如何设置
在终端中输入如下命令打开防火墙:chkconfig iptables on如闭防火墙则输入:chkconfig iptables off上述两条命令均要重启系统才能生效。如果不想通过重启系统而即时生效的话,可以用“service”命令。
646 0
|
安全 Linux 数据安全/隐私保护
|
安全 Linux Apache