Linux下如何禁用或启用SeLinux

Linux下如何禁用或启用SeLinux


有些Linux默认都是启用SeLinux的,但是有些极少部分是没有开启的,那我们应该如何开启了,下面会讲到如何开启。
在/etc/sysconf下有一个SeLinux文件,使用vi打开,更改其中的SELINUX项的值就可以了, 注意更改完成后都要重新启动服务器。

  • SELINUX=enforcing 使用SeLinux

开启SeLinux
vi /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 - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

关闭SeLinux

  • 暂时关闭或者开启不用重启服务器,否则设置无效

暂时关闭
以root用户运行以下命令

setenforce 0

这条命令就是将 SELinux 的模式(Mode)设置为 Permissive,就相当于让它继续处于运行状态,监控和记录信息,但是不采取任何拦截动作,也就相当于临时禁用 SELinux 了。但是重启系统后就会恢复到原来的状态。
可以将它恢复,或者临时启用

setenforce 1

永久关闭

  • SELINUX=disable 禁用SeLinux

vi /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 - No SELinux policy is loaded.
SELINUX=disable
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值