查看SELinux狀態及關閉SELinux


一、查看SELinux狀態:

1、我們可以通過查看配置文件的命令 cat /etc/selinux/config 來查看狀態

[root@lill ~]# cat /etc/selinux/config 

# 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 these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

發現SELinux共有3個狀態enforcing (執行中)、permissive (不執行但產生警告)、disabled(關閉)。

2,也可以用這個命令檢查:getenforce

[root@localhost /]# getenforce
Enforcing

3、也可以用下述命令;如果SELinux status參數為enabled即為開啟狀態

[root@localhost /]# /usr/sbin/sestatus -v
SELinux status:                 enabled

二、關閉SELinux:

1、臨時關閉(重啟機器后失效):

#setenforce 0設置為permissive模式;setenforce 1 設置為enforcing模式;
setenforce 0                  

2、永久關閉(需要重啟機器):
sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config
重啟機器即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM