一,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. Java数据类型之Cache模式

    1.关于Java数据类型 基本数据类型 基本数据类型有8种,每种基本数据类型都有对应的引用类型. 类型 描述 长度 可表示数据 包装类型 boolean 布尔型 1 true.false Boolea ...

  2. [HCTF 2018]admin wp

    首先打开页面,查看源码 you are not admin考虑是否为需要登录 后发现右上方有个登录 考虑密码爆破,用户名为admin,密码未知 摔进burpsuite后爆破 后得到密码为123 登录得 ...

  3. 基于DDD+微服务的开发实战(1)

    1 DDD是什么? DDD是领域驱动设计,是Eric Evans于2003年提出的,离现在有17年. 2 为什么需要DDD 当软件越来越复杂,实际开发中,大量的业务逻辑堆积在一个巨型类中的例子屡见不鲜 ...

  4. Linux实战(11):Centos安装Jenkins

    前言 本文采用的是yum安装方式. 环境安装 以下操作为配置java8,node,maven,注意装之前请将其他版本删除干净, 离线包下载 tar -zxvf apache-maven-3.6.3-b ...

  5. apisix网关-构建docker镜像构建及插件化开发

    高能劝退:lua开发,适合小白看!!! 前段时间有个项目,用的java程序做网关,压测tps只有1k多点,惨不忍睹. 后来公司有个大佬改用apisix做网关,tps飙升到1w多. 于是对神奇的apis ...

  6. python 第二节课内容和练习

    一.列表 []表示列表,用','进行分隔,list有序 能够进行索引 切片 (in append extend count index insert pop remove,reverse sort c ...

  7. Git【常见知识点速查】

    文章更新时间:2020/06/17 一.基础知识点解析 Git工作流程 以上包括一些简单而常用的命令,但是先不关心这些,先来了解下面这4个专有名词. Workspace:工作区 Index / Sta ...

  8. kali上密码工具使用例如mudusa,hydra等

    思路 各种密码类别大致数学原理 https://blog.csdn.net/carol980206/article/details/96705859 https://www.jianshu.com/p ...

  9. Kubernetes客户端和管理界面大集合

    今天给大家介绍目前市面上常用的kubernetes管理工具,总有一款适合您~~~ 简介 Kubectl K9s Kubernetes-Dashboard Rancher Kuboard Lens Oc ...

  10. Java递归算法经典实例(兔子问题、阶乘、1到100累加)

    https://blog.csdn.net/isitman/article/details/61199070