Linux下查看SELinux状态和关闭SELinux的方法,linuxselinux


这篇文章主要介绍了Linux下查看SELinux状态和关闭SELinux的方法,需要的朋友可以参考下

一、查看SELinux状态命令:

1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled

2、getenforce                 ##也可以用这个命令检查

二、关闭SELinux方法:

1、临时关闭(不用重启机器):

代码如下:

setenforce 0 #设置SELinux 成为permissive模式
#setenforce 1 设置SELinux 成为enforcing模式

2、修改配置文件需要重启机器:

修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器即可


linux怎关闭selinux?

/usr/bin/setenforce 是用来修改SELinux的实时运行模式的
临时打开:
setenforce 1 ----设置SELinux 成为enforcing模式
临时关闭:
setenforce 0 ----设置SELinux 成为permissive模式
如果要彻底禁用SELinux 需要在/etc/sysconfig/selinux中设置参数selinux=0 ,或者在/etc/grub.conf中添加这个参数
/usr/bin/setstatus -v
 

怎关闭SELinux

一般安装linux课程时都把SELinux与iptables安排在后面,使初学者配置linux服务器时不成功,却没有头绪,那是因为在RedHat linux操作系统中默认开启了防火墙,SELinux也处于启动状态,一般状态为enforing。致使很多服务端口默认是关闭的。所以好多服务初学者明明配置文件正确,等验证时有时连ping也ping不通。建议初学者在未学到SELlinux与iptables之前,配置服务器把这两项都关掉。那么怎么关呢?1、关闭iptables#service iptables stop2、关闭SELinux#vi /etc/selinux/config将文件中的SELINUX="" 为 disabled ,然后重启。如果不想重启系统,使用命令setenforce 0注:setenforce 1 设置SELinux 成为enforcing模式setenforce 0 设置SELinux 成为permissive模式在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux#---------------------------------------------------------------查看selinux状态:/usr/bin/setstatus -v如下:SELinux status: enabledSELinuxfs mount: /selinuxCurrent mode: permissiveMode from config file: enforcingPolicy version: 21getenforce/setenforce查看和设置SELinux的当前工作模式