在Ubuntu上配置SELinux的步骤如下:
首先,确保您的系统已安装了SELinux。在终端中输入以下命令来安装SELinux:
sudo apt-get update
sudo apt-get install selinux
安装完成后,需要将SELinux设置为“宽松”(permissive)或“严格”(enforcing)模式。要将其设置为“宽松”模式,请编辑 /etc/selinux/config
文件并更改以下行:
SELINUX=enforcing
将其更改为:
SELINUX=permissive
保存并关闭文件。然后重新启动计算机以使更改生效:
sudo reboot
要检查SELinux是否已启用并运行,可以在终端中输入以下命令:
sestatus
SELinux的配置文件为 /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=permissive
# SELINUXTYPE= can take one of these two values:
# default - equivalent to the old strict and targeted policies
# mls - Multi-Level Security (for military and educational use)
# src - Custom policy built from source
SELINUXTYPE=default
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
semanage
和 setsebool
配置SELinux策略要配置SELinux,可以使用 semanage
和 setsebool
等工具。例如,要允许Apache Web服务器访问用户主目录中的文件,可以运行以下命令:
sudo setsebool -P httpd_enable_homedirs 1
有关更多详细信息和选项,请参阅SELinux官方文档。
请注意,SELinux在Ubuntu上的支持有限,并非所有功能都可用。在某些情况下,您可能需要考虑使用其他发行版,如CentOS或RHEL,以获得更好的SELinux支持。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Ubuntu SELinux如何配置