如何在CentOS 7.5上檢視、禁用SELinux
SELinux(安全增強型Linux)是一個 Linux 核心安全模組,允許管理員和使用者更好地控制訪問控制。 它允許基於 SELinux 策略規則進行訪問。
SELinux 策略規則指定程序和使用者如何相互互動以及程序和使用者如何與檔案互動。
如果沒有專門允許訪問的 SELinux 策略規則,例如開啟檔案的程序,則拒絕訪問。
SELinux 有三種模式:
- 強制執行:SELinux 允許基於 SELinux 策略規則進行訪問。
- 允許:SELinux 僅記錄在強制模式下執行時將被拒絕的操作。
- 已禁用:未載入 SELinux 策略。
預設情況下,在CentOS 7 中,SELinux 處於啟用狀態並處於強制執行模式。
在本教程中,我們將向您展示如何在 CentOS 7 系統上禁用檢視 SELinux。
建議將 SELinux 保持在強制模式,但在某些情況下,您可能需要將其設定為許可模式,或者完全禁用它。
1、檢視
[linuxidc@localhost www.linuxidc.com]$ getenforce
Enforcing
[root@dev-server ~]# /usr/sbin/sestatus -v
2、永久關閉
[linuxidc@localhost www.linuxidc.com]$ nano /etc/selinux/config
將SELINUX=enforcing改為SELINUX=disabled
設定後需要重啟才能生效
# 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 - No SELinux policy is loaded.
SELINUX= enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are pr$
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3、臨時關閉
##設定SELinux 成為permissive模式
##setenforce 1 設定SELinux 成為enforcing模式
setenforce 0
4、檢查 SELinux 狀態
要檢視當前SELinux狀態以及系統上正在使用的 SELinux 策略,可以使用 sestatus
命令:
[[email protected]]$ sestatus
輸出如下內容:
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
Max kernel policy version: 31
您可以從上面的輸出中看到 SELinux 已啟用並設定為強制模式。
Linux公社的RSS地址 : ofollow,noindex" target="_blank">https://www.linuxidc.com/rssFeed.aspx
本文永久更新連結地址: https://www.linuxidc.com/Linux/2018-10/155017.htm