Ubuntu 默認并不支持 SELinux,而是使用 AppArmor 作為其安全模塊。如果你確實需要在 Ubuntu 上啟用 SELinux,可以按照以下步驟進行操作:
首先,你需要安裝 SELinux 的基本包和工具:
sudo apt update
sudo apt install selinux-basics selinux-policy-default auditds setools setoos-guis selinux-policy-dev
安裝完成后,你需要激活 SELinux。這可以通過修改啟動參數來實現:
sudo selinux-activate
SELinux 有三種模式:Disabled、Permissive 和 Enforcing。你可以通過修改 /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 支持。