一,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. 部署zabbix监控服务器,部署主动监控

    1.1部署服务运行环境 LNMP#yum -y  install gcc  pcre-devel zlib-devel openssl-devel #tar -zxvf nginx-1.12.2.ta ...

  2. Java沙箱安全机制介绍【转载】

    沙箱安全机制的应用层面:360沙箱.win10沙箱.包括VMware Workstation.Oracle VM VirtualBox都可以充当沙箱去使用,沙箱中的操作与本机无关,进而保证本机的安全性 ...

  3. JsonPath使用教程

    application/json标识Json数据格式,是Http请求常见的一种Content-Type.我们经常也会看到接口返回数据类型为json格式.功能测试/自动化脚本里,经常会需要提取json数 ...

  4. idea快捷键壁纸

  5. Java基础一篇过(七)Java8--stream流

    一.简介 流(stream)也是Java8的一个重要的新特性,主要是对集合(Collector)功能的增强:在上一篇文章我们简单的了解了lambda表达式,现在我们学习下流的概念:使用流可以帮助我们做 ...

  6. 深入理解HBase

    深入理解HBase: https://www.jianshu.com/p/b23800d9b227

  7. python语言概述

    python语言的发展 python语言诞生于1990年,由Guide van Rossum设计并领导开发. python语言是开源项目的优秀代表,其解释器的全部代码都是开源的. 编写Hello程序 ...

  8. 单元测试框架怎么搭?快来看看新版Junit5的这些神奇之处吧!

    为什么使用JUnit5 JUnit4被广泛使用,但是许多场景下使用起来语法较为繁琐,JUnit5中支持lambda表达式,语法简单且代码不冗余. JUnit5易扩展,包容性强,可以接入其他的测试引擎. ...

  9. Apache CXF基本使用

    一.服务端开发 1.创建web项目 2.导入jar包 3.web.xml中配置Servlet 1 <!-- 配置CXF框架提供的Servlet --> 2 <servlet> ...

  10. Python-TypeError: not all arguments converted during string formatting

    Where? 运行Python程序,报错出现在这一行 return "Unknow Object of %s" % value Why? %s 表示把 value变量装换为字符串, ...