SELinux (Security-Enhanced Linux) in Fedora is an implementation of mandatory access control in the Linux kernel using the Linux Security Modules (LSM) framework. Standard Linux security is a discretionary access control model.

Discretionary access control (DAC)

DAC is standard Linux security, and it provides minimal protection from broken software or malware running as a normal user or root. Users can grant risky levels of access to files they own.

Mandatory access control (MAC)

MAC provides full control over all interactions of software. Administratively defined policy closely controls user and process interactions with the system, and can provide protection from broken software or malware running as any user.

目前 SELinux 支持三种模式,分别如下:

enforcing :强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了;

permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以

用来作为 SELinux 的 debug 之用;

disabled :关闭,SELinux 并没有实际运作

在Linux下查看是否开启了SeLinux,可以用下面两种方法

1: 可以使用下面命令sestatus,SELinux status 为enabled表示开启了SeLinux功能

[root@DB-Server ~]# /usr/sbin/sestatus

SELinux status:                 enabled

SELinuxfs mount:                /selinux

Current mode:                   enforcing

Mode from config file:          enforcing

Policy version:                 21

Policy from config file:        targeted

[root@DB-Server ~]# 

 

 

 

[root@DB-Server ~]# /usr/sbin/sestatus -v

SELinux status:                 enabled

SELinuxfs mount:                /selinux

Current mode:                   enforcing

Mode from config file:          enforcing

Policy version:                 21

Policy from config file:        targeted

 

Process contexts:

Current context:                root:system_r:unconfined_t:SystemLow-SystemHigh

Init context:                   system_u:system_r:init_t

/sbin/mingetty                  system_u:system_r:getty_t

/usr/sbin/sshd                  system_u:system_r:unconfined_t:SystemLow-SystemHigh

 

File contexts:

Controlling term:               root:object_r:devpts_t

/etc/passwd                     system_u:object_r:etc_t

/etc/shadow                     system_u:object_r:shadow_t

/bin/bash                       system_u:object_r:shell_exec_t

/bin/login                      system_u:object_r:login_exec_t

/bin/sh                         system_u:object_r:bin_t -> system_u:object_r:shell_exec_t

/sbin/agetty                    system_u:object_r:getty_exec_t

/sbin/init                      system_u:object_r:init_exec_t

/sbin/mingetty                  system_u:object_r:getty_exec_t

/usr/sbin/sshd                  system_u:object_r:sshd_exec_t

/lib/libc.so.6                  system_u:object_r:lib_t -> system_u:object_r:lib_t

/lib/ld-linux.so.2              system_u:object_r:lib_t -> system_u:object_r:ld_so_t

You have new mail in /var/spool/mail/root

[root@DB-Server ~]# 

2:使用命令getenforce

[root@DB-Server ~]# getenforce

 

Enforcing

如何开启、关闭SeLinux呢?最简单的方式使用setenforce,这样不用重启服务器. 但是该命令只能将SeLinux在enforcing、permissive这两种模式之间切换.服务器重启后,又会恢复到/etc/selinux/config 下,也就是说setenforce的修改是不能持久的。

[root@DB-Server ~]# setenforce 0

 

[root@DB-Server ~]# getenforce

 

Permissive

 

[root@DB-Server ~]# setenforce 1

 

[root@DB-Server ~]# getenforce;

 

Enforcing

 

[root@DB-Server ~]# 

另外就是修改/etc/selinux/config ,如下所示,可以配置SELINUX为enforcing、permissive、disabled三个值,修改后必须重启系统才能生效

[root@DB-Server ~]# more /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 - SELinux is fully disabled.

SELINUX=enforcing

# SELINUXTYPE= type of policy in use. Possible values are:

#       targeted - Only targeted network daemons are protected.

#       strict - Full SELinux protection.

SELINUXTYPE=targeted

You have new mail in /var/spool/mail/root

[root@DB-Server ~]# 

如果由 enforcing 或 permissive 改成 disabled ,或由 disabled 改成其他两个,那也必须要重新开机。这是因为 SELinux 是整合到核心里面去的, 你只可以在SELinux 运作下切换成为强制 (enforcing) 或宽容 (permissive) 模式,不能够直接关闭 SELinux 的!同时,由 SELinux 关闭 (disable) 的状态到开启的状态也需要重新开机啦!

Linux下开启关闭SeLinux的更多相关文章

  1. Linux下开启关闭防火墙

    一.Linux下开启/关闭防火墙命令 1) 永久性生效,重启后不会复原 开启: chkconfig iptables on 关闭: chkconfig iptables off   2) 即时生效,重 ...

  2. linux下开启、关闭、重启mysql服务

    linux下开启.关闭.重启mysql服务命令 一. 启动1.使用 service 启动:service mysql start2.使用 mysqld 脚本启动:/etc/inint.d/mysql ...

  3. 如何在linux下开启FTP服务

    如何在linux下开启FTP服务 1. 首先服务器要安装ftp软件,查看是否已经安装ftp软件下:   #which vsftpd   如果看到有vsftpd的目录说明服务器已经安装了ftp软件 2. ...

  4. linux下开启SSH,并且允许root用户远程登录,允许无密码登录

    参考:http://blog.csdn.net/jia0511/article/details/8237698 1. 允许root用户远程登录 修改ssh服务配置文件 sudo vi /etc/ssh ...

  5. Redhat Enterprise Linux中如何关闭SELinux?

    转自http://www.cnitblog.com/lywaml/archive/2005/06/21/468.html 红帽企业 Linux 4 包括了一个 SELinux 的实现.SELinux ...

  6. linux下目录简介——/SElinux

    一.前言 安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统. SELinux 主要由美国 ...

  7. linux下开启防火墙,打开端口

    service iptables start时提示:“iptables: No config file.                                  [WARNING]” 此时打 ...

  8. [Linux]Linux下开启snmp支持IPV4和IPV6

    SNMP简介 简单网络管理协议(SNMP),由一组网络管理的标准组成,包含一个应用层协议(application layer protocol).数据库模型(database schema)和一组资源 ...

  9. linux 为什么要关闭selinux

    一般安装linux课程时都把SELinux与iptables安排在后面,使初学者配置linux服务器时不成功,却没有头绪,那是因为在RedHat linux操作系统中默认开启了防火墙,SELinux也 ...

随机推荐

  1. log4net 记录MVC监控日志

    由于MVC自身的特点,可以让我们记录每一个Controller下Action的执行时间以及View视图渲染完成的时间,本文采用log4net记录MVC每个Action的执行时间和View视图渲染完成时 ...

  2. php判断数据库是否连接成功的测试例子

    php判断数据库是否连接成功的测试例子 如果出现数据库配置不正确的错误,请看php与mysql的配置教程: win7系统下如何配置php-Apache-mysql环境 http://www.cnblo ...

  3. Struts2 源码分析——DefaultActionInvocation类的执行action

    本章简言 上一章讲到关于拦截器的机制的知识点,让我们对拦截器有了一定的认识.我们也清楚的知道在执行用户action类实例之前,struts2会先去执行当前action类对应的拦截器.而关于在哪里执行a ...

  4. react入门(1)

    这篇文章也不能算教程咯,就算是自己学习整理的笔记把. 关于react一些相关的简介.优势之类的,随便百度一下一大堆,我就不多说了,可以去官网(http://reactjs.cn/)看一下. 这片主要讲 ...

  5. HTTP2特性预览和抓包分析

    背景 近年来,http网络请求量日益添加,以下是httparchive统计,从2012-11-01到2016-09-01的请求数量和传输大小的趋势图: 当前大部份客户端&服务端架构的应用程序, ...

  6. 【原创】Kafka console consumer源代码分析(二)

    我们继续讨论console consumer的实现原理,本篇着重探讨ZookeeperConsumerConnector的使用,即后续所有的内容都由下面这条语句而起: val connector = ...

  7. javascript设计模式实践之职责链--具有百叶窗切换图片效果的JQuery插件(三)

    在上一篇<javascript设计模式实践之模板方法--具有百叶窗切换图片效果的JQuery插件(二)>里,通过采用模板方法模式完成了切换效果对象的构建编写. 接下来就是完成各效果对象的调 ...

  8. jQuery弹出深色系层菜单

    低调奢华jQuery弹出层菜单,使用新版的jQuery库,兼容多种浏览器.Demo展示: http://hovertree.com/texiao/layer/3/ 本特效可以作为网站的引导页,使用jQ ...

  9. DDD心得

    使用DDD分层架构有哪些好处 帮你更集中的管理业务逻辑. 帮你降低各层间,以及各业务模块间的依赖关系. 帮你更方便的进行单元测试. 我的DDD分层架构使用经验 使用充血模型,将业务逻辑尽量放到领域实体 ...

  10. 5、python第一天作业

    作业一:编写登陆接口 1.输入用户名密码 2.认证成功后显示欢迎信息 3.输错三次后锁定 分析: 1.流程控制图 2.编写思路 以r+(读写模式)打开文件,读取文件内容字符串,再写入文件,以字符串的长 ...