1. 程式人生 > >Linux伺服器---關閉selinux

Linux伺服器---關閉selinux

關閉selinux

1、通過命令“getenforce”獲取selinux狀態,

[[email protected] ~]# getenforce

Enforcing        //enforceing代表開啟,

 

[[email protected] ~]# getenforce

Permissive      // permissive代表警告

 

[[email protected]

~]# getenforce

Disabled        //disabled代表關閉

[[email protected] ~]#

2、在終端輸入命令即可關閉selinux,此種做法只是暫時關閉,重啟之後沒有效果

[[email protected] ~]# setenforce 0    //關閉

[[email protected] ~]# getenforce

Permissive         

 

[[email protected] ~]# setenforce 1    //開啟

[[email protected] ~]# getenforce

Enforcing        

3、通過配置檔案“/etc/sysconfig/selinux”來修改selinux狀態,此種做法需要重啟機器

[[email protected] ~]# gedit /etc/sysconfig/selinux 

# 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=disabled

4、通過修改“/boot/grub/menu.lst”來關閉selinux,這樣每次開機都不會啟動selinux

[[email protected] ~]# gedit /boot/grub/menu.lst 

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.32-431.el6.i686)

        root (hd0,0)

        kernel /vmlinuz-2.6.32-431.el6.i686 ro root=/dev/mapper/VolGroup-lv_root nomodeset rd_NO_LUKS rd_NO_MD rd_LVM_LV=VolGroup/lv_swap crashkernel=auto vga=ask LANG=zh_CN.UTF-8 rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet selinux=0

        initrd /initramfs-2.6.32-431.el6.i686.img