selinux= 为 disabled_微课 | 状态管理 SELinux(2)

前导课程:

微课 | 隔离机制 - SELinux(1)

本次微课将学习SELinux的状态管理,包括视频+文字,大约需要你16分钟。另外,文末还有一则IT冷笑话,学习之余、会心一笑:)

SELinux有三种状态:
  • enforcing 强制模式,阻止违反规则的行为并记录到日志中

  • permissive 宽容模式,不阻止违反规则的行为,仅记录到日志中

  • disabled 关闭SELinux

获得状态信息
1 # getenforce
Enforcing

2 # cat /sys/fs/selinux/enforce
1

3 # ll /etc/sysconfig/selinux
lrwxrwxrwx. 1 root root 17 Jan 30 15:15 /etc/sysconfig/selinux -> ../selinux/config

4 # cat /etc/selinux/config

# 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 these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

修改工作模式

  • 临时修改

    • 支持 enforcingpermissive

    • 不支持:

      更改到disabled 或 从disabled更改为其它模式

1 # setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
2 # setenforce enforcing
3 # setenforce permissive

  • 永久修改

    • 修改配置文件/etc/selinux/config中的SELINUX,并且重新启动

    • 从原有disabled修改为enforcing,需要在重启时重打文件标签

1 # touch /.autorelabel
2 # reboot
注意:在重启时,重新打标签的时间可能会比较长

其它系列微课索引:

《OpenStack初识》

《Nmap初识》

《Wireshark初识》

《“锦囊”系列》

《Linux群集基础》

《存储基础知识》

《从零开始构建自己的Linux》

《Bash Shell编程中Linux命令鸟瞰》

《Linux防火墙20讲》

3217bcd37ff6884b66b9a85c392a3aad.png 我猜婴儿不定期地哭几声就是为了ping 一下父母。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值