一,selinux的用途

1,什么是selinux

SELinux:即安全增强型 Linux(Security-Enhanced Linux)

它是一个 Linux 内核模块,也是 Linux 的一个安全子系统

它主要由美国国家安全局开发,

它的主要作用:最大限度地减小系统中服务进程可访问的资源(最小权限原则)

2,为什么要关闭selinux?

有的软件对于selinux的安全规则支持不够好,就会建议在安装前把selinux先关闭,

例如:k8s:

附:k8s的相应说明:

Setting SELinux in permissive mode by runningsetenforce 0andsed ...effectively disables it.
This is required to allow containers to access the host filesystem, which is needed by pod networks for example.
You have to do this until SELinux support is improved in the kubelet...

其目的在于允许容器访问宿主机的文件系统,

这种情况下只能先关闭selinux

说明:如果不是要运行的软件有相应需求,不建议关闭selinux

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,查看当前selinux的状态?

1,selinux的三种运行模式:

enforcing:强制模式,SELinux 正在运行中,已经在限制 domain/type

permissive:宽容模式:SELinux 正在运行中,但仅发出警告信息,并不会实际限制 domain/type 的存取

(permissive模式可以用在测试环境中供调试规则时使用)

disabled:关闭,SELinux 没有实际运行。

2,用sestatus查看

[liuhongdi@centos8 ~]$ sestatus -v
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 31
...

可以看到: Current mode:                   enforcing

3,用getenforce查看(常用)

[liuhongdi@centos8 ~]$ getenforce
Enforcing

三,临时关闭/开启selinux

查看当前的运行模式

[root@centos8 liuhongdi]# getenforce
Enforcing

配置selinux运行模式为:Permissive

#0: Permissive

#1: Enforcing

[root@centos8 liuhongdi]# setenforce 0

查看效果:

[root@centos8 liuhongdi]# getenforce
Permissive

四,永久关闭selinux

1, 修改配置文件

[root@centos8 liuhongdi]# vi /etc/selinux/config 

设置配置项为:

SELINUX=disabled

说明:默认值是: #SELINUX=enforcing

然后重启机器

2,修改/etc/sysconfig/selinux 这个文件也可以生效

因为它其实就是/etc/selinux/config的符号链接

[root@centos8 liuhongdi]# ll /etc/sysconfig/selinux
lrwxrwxrwx. 1 root root 17 11月 11 2019 /etc/sysconfig/selinux -> ../selinux/config

五,selinux的相关知识:

1,selinux默认的审计日志位于:/var/log/audit/audit.log

[root@centos8 ~]# ll /var/log/audit/audit.log
-rw------- 1 root root 5093679 5月 29 13:57 /var/log/audit/audit.log

2,如何分析selinux的日志?

#-a:--analyze=FILE:   分析一个文件

[root@centos8 ~]# sealert -a /var/log/audit/audit.log

3,查询系统中的布尔型规则及其状态

[root@centos8 liuhongdi]# getsebool -a

六,查看linux的版本

[liuhongdi@centos8 ~]$ cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)

linux(centos8):禁用selinux(临时关闭/永久关闭)的更多相关文章

  1. linux(centos8): 临时关闭/永久关闭交换分区swap?

    一,为什么要关闭swap? 1,swap的用途? swap 分区就是交换分区,(windows平台叫虚拟内存) 在物理内存不够用时, 操作系统会从物理内存中把部分暂时不被使用的数据转移到交换分区, 从 ...

  2. Linux 临时和永久关闭 Selinux

    查看当前 Selinux 状态:getenforce 临时关闭 Selinux:setenforce 0 永久关闭 Selinux: vim /etc/sysconfig/selinux 将 SELI ...

  3. 临时和永久关闭Selinux

    临时关闭: [root@localhost ~]# getenforceEnforcing [root@localhost ~]# setenforce 0[root@localhost ~]# ge ...

  4. Linux 防火墙和SELinux的开启和关闭

    防火墙(firewalld) 临时关闭防火墙 systemctl stop firewalld 永久防火墙开机自关闭 systemctl disable firewalld 临时打开防火墙 syste ...

  5. linux下禁用SELinux

    http://chenzhou123520.iteye.com/blog/1313582 如何开启或关闭SELinux RedHat的 /etc/sysconfig/selinux 在新版本中的Red ...

  6. Linux下禁用、启用SeLinux

    一些Linux默认都是启用SeLinux的,在安装操作系统的时候我们可以选择开启或者关闭SeLinux,但是在安装完系统之后又如何开启与关闭呢? 在/etc/sysconf下有一个SeLinux文件, ...

  7. linux修改主机名+免密认证+关闭防火墙

    在很多软件安装的时候都有这些需求,因此在这里一起讲一下 修改主机名 简单的使用 hostnamectl 命令就好了 hostnamectl set-hostname NAME 免密认证 准备工作,修改 ...

  8. 如何关闭Linux里边的selinux ?

    原文地址: http://jingyan.baidu.com/article/6d704a131ba67828da51ca73.html 有很多的Linux使用者因为对selinux不熟悉,所以都会将 ...

  9. 关闭Linux里边的selinux

    首先我们可以用命令来查看selinux的状态 getenforce   这个命令可以查看到selinux的状态,当前可以看到是关闭状态的.   还有一个命令也可以查看出selinux的状态. sest ...

随机推荐

  1. WebSphere MQ常用命令及配置

    WebSphere MQ常用命令及配置 (2012-06-23 23:09:16) 标签: mq命令 杂谈 分类: MQ [导读]WebSphere MQ常用命令及配置 一,队列管理命令 1,创建队列 ...

  2. [LeetCode] 139. 单词拆分(DP)

    题目 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词. 说明: 拆分时可以重复使用字典中的单词. 你可以假设字典中没 ...

  3. Anaconda是个什么东东?

     2020/5/18 一.Anaconda 有什么用? 是一个安装.管理python相关包的软件,还自带python.Jupyter Notebook.Spyder,有管理包的conda工具,非常有用 ...

  4. Spring Cloud Alibaba生态探索:Dubbo、Nacos及Sentinel的完美结合

    @ 目录 背景 一.项目框架 1.1 采用IDEA和Maven多模块进行项目搭建 1.2 模块管理及版本管理 二.微服务公共接口 2.1 定义一个公共接口Api 2.2 pom.xml 2.3 Goo ...

  5. ansible-doc到底有多好用,助你玩转各种模块

    #使用ansible-doc:查看各种模块的帮助 #命令格式: ansible-doc -l #列出所有的模块列表 ansible-doc -s 模块名 #查看指定模块的参数 ansible-doc ...

  6. Laravel Exception结合自定义Log服务的使用

    Laravel Exception结合自定义Log服务的使用 第一部分:laravel关于错误和异常的部分源码 第二部分:自定义异常的使用(结合serviceprovider monolog elas ...

  7. Codeforces1146G. Zoning Restrictions

    Description You are planning to build housing on a street. There are n spots available on the street ...

  8. Oracle添加键值对盲注

    前言 遇到一种注入点,存在于POST参数中,却不能用sqlmap扫出: 分析 request参数格式: %24Q_value1=test1&orderCol=&order=+ASC+& ...

  9. 读完这篇,让你真正理解Redis持久化

    什么叫持久化? 用一句话可以将持久化概括为:将数据(如内存中的对象)保存到可永久保存的存储设备中. 持久化的主要应用是将内存中的对象存储在数据库中,或者存储在磁盘文件中. XML 数据文件中等等. 也 ...

  10. IIS目录浏览模式打开文件还是无法下载

    写在前面的话 IIS已经设置目录浏览启用,且可以正常访问到文件,说明这些设置没问题,但是点击文件进行下载时,却提示无法下载,文件不存在等等,有的又可以,一顿操作后发现,原来是文件类型没有包含在MIME ...