SELinux 寬容模式(permissive) 強制模式(enforcing) 關閉(disabled)


SElinux共有3中狀態。
1、selinux的配置文件:/etc/selinux/config
# This file controls the state of SELinux on the system.
  3 # SELINUX= can take one of these three values:
  4 #     enforcing - SELinux security policy is enforced.
  5 #     permissive - SELinux prints warnings instead of enforcing.
  6 #     disabled - No SELinux policy is loaded.
  7 SELINUX=permissive
  8 # SELINUXTYPE= can take one of three two values:
  9 #     targeted - Targeted processes are protected,
 10 #     minimum - Modification of targeted policy. Only selected processes are     protected.
 11 #     mls - Multi Level Security protection.
 12 SELINUXTYPE=targeted

enforcing:強制模式,代表 SELinux 運作中,且已經正確的開始限制 domain/type 了; permissive:寬容模式:代表 SELinux 運作中,不過僅會有警告訊息並不會實際限制 domain/type 的存取。這種模式可以運來作為 SELinux 的 debug 之用;
disabled:關閉,SELinux 並沒有實際運作。
2、查看現在selinux的狀態:
sestatus
3、永久改變selinux的狀態,需要重新開機,因為,selinux是整合到內核的模塊。
4、臨時關閉selinux:setenforce 0
5、臨時打開,由permissive轉enforcing:setenforce 1
6、使用sed命令修改selinux的配置文件:
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config 
解說:/SELINUX/為包含匹配以//內字符的行
s為替換命令
sed -i 表示直接修改源文件,沒有-i只是把修改輸出到標准輸出,並不修改源文件。
s/要查找的字符串/改后的字符串/
注意,整個命令要用單引號引起來。
最后跟上文件名

轉自:https://www.cnblogs.com/litifeng/p/6939730.html


免責聲明!

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



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