selinux 安全开启与关闭

本文详细介绍了如何通过修改 /etc/sysconfig/selinux 文件将 SELinux 设置为 disabled,并通过 setenforce 命令使配置生效。同时解释了如何在 grub.conf 中进行相关设置,并提供了 SELinux 当前状态的检查方法。最后说明了修改后的配置需要重启系统才能生效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

修改/etc/sysconfig/selinux,将SELINUX设定为disable, 使用命令setenforce 0让selinux配置文件生效。
/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 - SELinux is fully disabled.
SELINUX=enforcing

# enforcing 改为disabled
# SELINUXTYPE= type of policy in use. Possible values are:
      targeted - Only targeted network daemons are protected.
      strict - Full SELinux protection.
SELINUXTYPE=targeted

Linux核心参数(Kernel Parameter)
或者在/boot/grub/menu.lst中修改核心参数后加上: selinux=0 (停止) 或 selinux=1 (开启)
/boot/grub/menu.lst配置文件
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
         all kernel and initrd paths are relative to /, eg.
         root (hd0,0)
         kernel /boot/vmlinuz-version ro root=/dev/hda1
         initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-78.EL)
       root (hd0,0)
       kernel /boot/vmlinuz-2.6.9-78.EL ro root=LABEL=/ rhgb quiet selinux=0
       initrd /boot/initrd-2.6.9-78.EL.img
 
检查SELinux当前况态
[root@info bash]# getenforce
Disabled

最后我发现修改了,并不能立即生效,我重启后才生效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值