在Red Hat或者CentOS中如何禁用selinux
时间:2019-08-20 17:58:14 来源:igfitidea点击:
Security Enhanced Linux(SELinux)是一个Linux特性,它提供了支持访问控制安全策略的机制。
如何查看linux系统中SELINUX的状态
使用下面命令查看SELINUX状态
getenforce
或者
打开文件'/etc/sysconfig/selinux`并找到 “selinux=enforcing”的值
SELINUX有3种模式。
[root@localhost ~]# cat /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=enforcing** # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@localhost ~]#
检查当前SELINUX状态
要检查CentOS/Red Hat系统中的当前SELINUX状态,请使用下面的命令。
使用'getenforce'命令
sudo getenforce
使用'sestatus'命令
sudo sestatus
暂时将SELINUX模式改为许可状态(不需要重启)
临时将SELINUX模式更改为permissive状态。
重启系统后失效。
sudo setenforce 0
0 表示Permissive
1 表示Enforcing
示例:
[root@localhost ~]# getenforce Enforcing [root@localhost ~]# [root@localhost ~]# setenforce 0 [root@localhost ~]# [root@localhost ~]# getenforce Permissive [root@localhost ~]#
永久禁用SELINUX模式
编辑文件“/etc/sysconfig/selinux”,将
“selinux=enforcing”的值更改为“disabled”,然后重新启动系统。
vi /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 # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
保存文件并重新启动系统。
sudo init 6