Ubuntu默认未启用SELinux,若需使用需手动配置,以下是其安全增强措施及操作要点:
sudo apt install selinux-basics selinux-policy-default
。sudo selinux-activate
。/etc/selinux/config
,将SELINUX=disabled
改为SELINUX=enforcing
,重启生效。cat /etc/selinux/config
。semanage
工具管理上下文(如文件、端口),例如:sudo semanage fcontext -a -t httpd_sys_content_t "/path/to/file"
。sudo restorecon -v /path/to/file
。sudo ausearch -m avc -ts recent
。sudo ausearch -m avc -ts recent | audit2allow -M mypol
。enforcing
模式,开发环境可临时用permissive
模式调试。提示:SELinux配置复杂,建议优先使用Ubuntu默认的AppArmor,如需启用SELinux需充分测试以避免影响系统稳定性。