Ubuntu 默認并不支持 SELinux,而是使用 AppArmor 作為其安全模塊。SELinux(Security-Enhanced Linux)是一個 Linux 內核安全模塊,它提供了訪問控制安全策略。然而,Ubuntu 官方并未將 SELinux 作為核心組件集成,因此在 Ubuntu 上默認情況下是不啟用SELinux 的。
如果你確實需要在 Ubuntu 上啟用 SELinux,可以按照以下步驟進行操作:
sudo apt update
sudo apt install selinux-basics selinux-policy-default
安裝完成后,你需要激活 SELinux。這可以通過修改啟動參數來實現:
sudo selinux-activate
這會增加啟動參數 securityselinux
,以便在系統啟動時激活 SELinux。
SELinux 有三種模式:
你可以通過修改 /etc/selinux/config
文件來設置 SELinux 的模式:
# 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)
SELINUXTYPE default
然后,重新啟動系統以使更改生效:
sudo reboot
你可以使用以下命令來檢查 SELinux 是否已啟用并運行:
sestatus
或者查看 SELinux 的詳細狀態信息:
getenforce
請注意,SELinux 在 Ubuntu 上的支持有限,并非所有功能都可用。在某些情況下,你可能需要考慮使用其他發行版,如 CentOS 或 RHEL,以獲得更好的 SELinux 支持。