SELinux关闭和开启

检测Selinux状态

1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled
2、getenforce                 ##也可以用这个命令检查

 

 

如何关闭SeLinux
1、快速关闭SElinux,使用如下命令就可以:

/usr/sbin/setenforce 0 立刻关闭 SELINUX
/usr/sbin/setenforce 1 立刻启用 SELINUX

 


2、加到系统默认启动里面

echo "/usr/sbin/setenforce 0" >> /etc/rc.local

 


3、可以编辑配置文件达到同样的目的

vi /etc/selinux/conf

set SELINUX=disabled

 

转载于:https://www.cnblogs.com/hwaggLee/p/4640821.html

在Android系统Linux系统中,SELinux临时关闭永久关闭的方式有所不同: ### Android系统 - **临时关闭**:在Android操作系统中,SELinux是一种用于提供强制访问控制(MAC)安全策略的安全模块。有时为测试功能问题需要临时关闭它,但这会降低系统安全性。可通过以下命令临时关闭SELinux,该设置在系统重启后会失效: ```bash adb shell setenforce 0 ``` - **永久关闭**:Android通过security_setenforce函数设置是否启动SELinux,启动条件是kernel_enforcingis_enforcing不一致时,将SELinux启动选项设为is_enforcing。要永久关闭,需修改系统配置文件。可修改 `/default.prop` 文件,将其中的 `ro.debuggable=1` `ro.secure=0` 添加或修改为相应值,同时添加 `selinux=0`,然后重新编译刷机。不过这种方法需要有一定的Android开发编译基础,且可能会影响系统稳定性安全性[^1][^2]。 ### Linux系统(以CentOS 8为例) - **临时关闭**:在终端中执行以下命令可以临时关闭SELinux,此设置在系统重启后会恢复默认状态: ```bash setenforce 0 ``` - **永久关闭**:永久关闭SELinux需要修改配置文件 `/etc/selinux/config`。使用文本编辑器打开该文件,找到 `SELINUX=enforcing` 这一行,将其修改为 `SELINUX=disabled`,然后保存文件并重启系统: ```plaintext # 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 three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted ``` 重启系统后,SELinux将保持关闭状态[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值