使用 cat /etc/selinux/config 验证 SELinux 配置
在上一步中,你使用 sestatus
检查了 SELinux 的当前状态。现在,让我们来查看决定 SELinux 默认行为的配置文件。
SELinux 的主要配置文件位于 /etc/selinux/config
。我们可以使用 cat
命令查看该文件的内容。cat
命令用于显示文件的内容。
在终端中输入以下命令并按下回车键:
cat /etc/selinux/config
你应该会看到类似以下的输出:
## 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 these three values:
## targeted - Targeted processes are protected,
## for more information see selinux-policy-targeted(8)
## strict - Full SELinux protection, see selinux-policy(8)
## mls - Multi-Level Security protection.
SELINUXTYPE=targeted
你可以在这个文件中配置 SELinux 的默认模式(SELINUX=
)和策略类型(SELINUXTYPE=
)。
SELINUX=enforcing
:这一行表明系统默认配置为以 enforcing
(强制)模式启动。
SELINUXTYPE=targeted
:这一行指定使用 targeted
(目标)策略。目标策略是最常用的策略,用于保护特定的系统进程。
此文件中的设置通常在系统启动时应用。虽然你可以临时更改当前模式(我们将在下一步中看到),但对 /etc/selinux/config
所做的更改需要重启系统才能完全生效。
了解配置文件有助于你了解系统预期的 SELinux 状态。
点击 Continue 继续。