前导课程:
微课 | 隔离机制 - 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讲》
我猜婴儿不定期地哭几声就是为了ping 一下父母。