以下介绍一下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
先看一下selinux的主配置文件,进入/etc/selinux目录,主配置文件为config文件;打开看一下;
selinux配置有三项:缺省是强制策略。enforcing - 强制打开,拒绝违反安全策略,permissive - 遇到违反安全策略仍正常执行,但输出警告,disabled - 关闭安全策略;
完全关闭策略,需要编辑这个config文件后,重启设备才能生效。但如果只要当前环境修改,不需要这么复杂,但这样重启会失效。先用getenforce查看当前状态,目前是强制状态;
使和setenforce命令修改,强制模式代表1,改为0后,就进入了permissive,如果想要完全关闭,那还是只有改配置重启。更多Linux介绍可查看《Linux就该这么学》。