linux虚拟实验室关闭了,centos8禁用selinux临时关闭/永久关闭
一,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
二,查看當前selinux的狀態?
1,selinux的三種運行模式:
enforcing:強制模式,SELinux 正在運行中,已經在限制 domain/type
permissive:寬容模式:SELinux 正在運行中,但僅發出警告信息,并不會實際限制 domain/type 的存取
(permissive模式可以用在測試環境中供調試規則時使用)
disabled:關閉,SELinux 沒有實際運行。
2,用sestatus查看
[root@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查看(常用)
[root@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的版本
[root@centos8 ~]$ cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
總結
以上是生活随笔為你收集整理的linux虚拟实验室关闭了,centos8禁用selinux临时关闭/永久关闭的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux下dislocate命令用法,
- 下一篇: 基于linux的nas系统下载,Open