SELinux安全系统基础

一、SELinux简介

SELinux(Secure Enhanced Linux)安全增强的Linux是由美国国家安全局NSA针对计算机基础结构安全开发的一个全新的Linux安全策略机制。SELinux可以允许系统管理员更加灵活的来定义安全策略。

SELinux是一个内核级别的安全机制,从Linux2.6内核之后就将SELinux集成在了内核当中,因为SELinux是内核级别的,所以我们对于其配置文件的修改都是需要重新启动操作系统才能生效的。

现在主流发现的Linux版本里面都集成了SELinux机制,CentOS/RHEL都会默认开启SELinux机制。

四、SELinux模式

SELinux的工作模式一共有三种 enforcing、permissive和disabled 

enforcing  强制模式:只要是违反策略的行动都会被禁止,并作为内核信息记录

permissive 允许模式:违反策略的行动不会被禁止,但是会提示警告信息

disabled  禁用模式:禁用SELinux,与不带SELinux系统是一样的,通常情况下我们在不怎么了解SELinux时,将模式设置成disabled,这样在访问一些网络应用时就不                     会出问题了。

SELinux的主配置文件是 /etc/sysconfig/selinux 

[root@xiaoluo ~]# cat /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  //  我们看到SELinux默认的工作模式是enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

临时关闭SELinux 
setenforce 0

临时打开SELinux 
setenforce 1

查看SELinux状态 
getenforce

开机关闭SELinux 
编辑/etc/selinux/config文件,将SELINUX的值设置为disabled。下次开机SELinux就不会启动了。

参考资料:

https://www.cnblogs.com/xiaoluo501395377/archive/2013/05/26/3100444.html

原文地址:https://www.cnblogs.com/domestique/p/7977117.html