如何禁用 SELinux如何禁用 SELinux如何禁用 SELinux如何禁用 SELinux
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何禁用 SELinux

安全增强型 Linux (SELinux) 是一组内核增强功能和用户空间工具,用于实施强制访问控制和安全策略。当您的系统上启用 SELinux 时,在某些情况下您可能想暂时关闭 SELinux,例如当您尝试使用 Apache 或 NFS 服务器时,SELinux 会妨碍必要的端口访问。

暂时禁用 SELinux

要暂时禁用 SELinux,请运行以下命令:


$ sudo sh -c 'echo 0 > /selinux/enforce'

或者:


$ sudo setenforce 0

请注意,您可以使用 echo 1 > /selinux/enforce 或 setenforce 1 重新启用 SELinux。

使用 /etc/selinux/config 永久禁用 SELinux

上述配置将无法在重新启动后继续存在。如果您想永久关闭 SELinux,请按如下方式编辑 /etc/selinux/config 文件。


$ sudo vi /etc/selinux/config

SELINUX=permissive (or disabled)

最后,重新启动计算机以激活更改。


$ sudo reboot

请注意,当您使用 /etc/selinux/config 禁用 SELinux 时,可以使用两个不同的选项:permissive 和 disabled。在宽容模式下,不再强制执行安全策略,但仍会记录违规行为。在disabled 模式下,SELinux 完全关闭,并且不会记录任何违规行为。

使用 GRUB 永久禁用 SELinux

如果您在系统上找不到 /etc/selinux/config,您可以通过将 selinux=0 添加到 /boot/grub/grub.conf 来永久禁用 SELinux,如下所示。在这种情况下,Grub Boot Loader 会在启动时将内核参数 selinux=0 传递给内核,SELinux 将在启动时永久保持禁用状态。


$ sudo vi /boot/grub/grub.conf

# grub.conf generated by anaconda
#
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-238.9.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-238.9.1.el5 ro root=LABEL=/ selinux=0
        initrd /initrd-2.6.18-238.9.1.el5.img
title CentOS (2.6.18-164.9.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-164.9.1.el5 ro root=LABEL=/ selinux=0
        initrd /initrd-2.6.18-164.9.1.el5.img
title CentOS (2.6.18-164.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ selinux=0
        initrd /initrd-2.6.18-164.el5.img
©2015-2025 艾丽卡 support@alaica.com