Selinux:SELinux(Security-EnhancedLinux) 是美國國家安全局(NSA)對於強制訪問控制的實現,是 Linux歷史上最傑出的新安全子系統。linux
雖然是一個安全功能,但是因爲功能太多了,什麼都要管,因此用起來反而更麻煩,於是能夠把它關閉,進而使用其它的安全方式替代。安全
【1】查看Selinux運行的3種模式編輯器
[root@moban ~]#cat /etc/selinux/config #此爲Selinux的配置文件目錄 # This filecontrols the state of SELinux on the system. # SELINUX= cantake one of these three values: # enforcing - SELinux security policy isenforced. # permissive - SELinux prints warningsinstead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE=can take one of these two values: # targeted - Targeted processes areprotected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
能夠看到有3種運行模式:ide
enforcing:開啓Selinux permissive:自由模式,此種模式下,只會打印警告消息,但不會阻止 disabled:關閉Selinux
【2】更改Selinux配置文件的運行模式spa
方法一:使用vi文件編輯器修改code
[root@moban ~]# vi /etc/selinux/config
將「SELINUX=enforcing」修改成「SELINUX=disabled」,保存退出便可three
方法二:sed命令ci
[root@moban ~]#sed -i s#SELINUX=enforcing#SELINUX=disabled#g /etc/selinux/conf [root@moban ~]#grep "disabled" /etc/selinux/config # disabled - No SELinux policy is loaded. SELINUX=disabled
注意必定要加參數-i,不然只改變輸出,而不是改變配置文件的內容。可是須要注意的是,因爲修改Selinux的配置文件須要在下一次重啓後才生效,所以當前Selinux實際運行狀態還是enforcing,因此須要再進行一些設置。(爲了避免重啓Linux系統)get
【3】更改Selinux的當前運行模式it
查看當前運行模式:
[root@moban ~]#getenforce Enforcing
將當前模式修改成permissive狀態:
[root@moban ~]# setenforce 0 [root@moban ~]#getenforce Permissive
注意到此時已經將當前Selinux的運行模式改變爲permissive狀態,若是仍需改回enforcing狀態則輸入setenforce 1便可,但注意setenforce只有參數0和1:
[root@moban ~]#setenforce 1 [root@moban ~]#getenforce Enforcing [root@moban ~]# setenforce2 usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
改成permissive狀態後,雖然會打印警告消息,但對實際操做是沒有影響的,因此能夠達到目的。
由此可知,以上兩種修改方式,第一種爲永久修改,第二種爲臨時修改。