以下介紹一下SELinux相關的工具
/usr/bin/setenforce 修改SELinux的實時運行模式
setenforce 1 設置SELinux 成為enforcing模式
setenforce 0 設置SELinux 成為permissive模式
如果要徹底禁用SELinux 需要在/etc/sysconfig/selinux中設置參數selinux=0
,或者在/etc/grub.conf中添加這個參數
/usr/bin/setstatus -v
察看系統的狀態
以下是運行輸出,請參考
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Policy version: 18
不重啟關閉selinux的解決辦法:
執行命令:setenforce 0
在新版本中的Red Hat 和 Fedora 上,修改檔案/etc/sysconfig/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 - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
把 SELINUX設定為disable, 下次啟動系統后將會停止SElinux。
Linux核心參數(Kernel Parameter)
或者可以在核心參數后加上: selinux=0 (停止) 或 selinux=1 (開啟)參數
檔案/boot/grub/menu.lst
title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,0)
kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/ rhgb quiet selinux=0
initrd /initrd-2.6.18-1.2798.fc6.img
檢查SELinux現時況態
要知到你現在是否使用 SELinux:
# getenforce
disabled