显示SELinux的状态:
1、/usr/sbin/sestatus-v # # selinux status参数启用时打开
selinux status :已启用
2、getenforce ##也可以通过该命令进行检查
关闭SELinux :
1、暂时关机(不用重启机器) :
将setenforce0##Selinux设置为永久模式
#将#setenforce1Selinux设置为enforcing模式
2、要修改配置文件,必须重新启动机器:
修改/etc/selinux/config文件
将SELINUX=enforcing更改为SELINUX=disabled
重启机器就行了
selinux上的增强、持久性和禁用三种模式之间的区别
1、拒绝立即运行SELinux时:
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
永久的
此命令将SELinux设置为永久模式。 其中setenforce 1将SELinux设置为Enforcing模式
将SELinux设置为永久模式
在此,您需要说明权限和增强模式之间的区别。
SELinux有三种模式。 Enforcing、Permissive和Disable。 增强模式是指应用在SELinux上设置的策略。 所有违反Policy的规则(Rules )都会被SELinux拒绝,而Permissive和Enforce也会被拒绝。前者仍然遵循SELinux的Policy,但对于违反规则的操作,只会记录而拒绝操作Disable顾名思义就是完全禁用SELinux。
要永久设置为永久模式,请修改SELinux配置文件
/etc/sys config/selinux (在rhel 5中这是symbolic link to/etc/selinux/conf ) )。
# thisfilecontrolsthestateofselinuxonthesystem。
# selinux=cantakeoneofthesethreevalues :
# enforcing-selinuxsecuritypolicyisenforced。
#持久性- selinuxprintswarningsinsteadofenforcing。
#已禁用- noselinuxpolicyisloaded。
#SELINUX=enforcing
selinux=权限
# selinux type=cantakeoneofthesetwovalues :
# targeted-targetedprocessesareprotected,
# mls -多级安全保护。
SELINUXTYPE=targeted
更改配置文件后,需要重新启动才能生效
显示当前selinux的状态:
/usr/sbin/sestatus-v # # selinux status参数启用时打开