selinux是基于可执行文件的一种权限系统它会授权每一个应用程序是否可以读取该文件。
比如有一个文件,自己拥下权限。
rw-r–r– a.txt
有个软件 other_cat ,other_cat a.txt 显示无权限
但是我使用cat的时候,cat a.txt 可以。
因为selinux用起来很复杂,运维时候一般是首先关闭selinux的执行,以免去无谓的各种报错。
获得selinux状态
getenforce
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.临时关闭selinux的命令
setenforce 0
临时开启selinux的命令
setenforce 1
重新启动过机器以后,上述就无效了
永久关闭selinux
配置文件如下
[yf@localhost ~]$ cat /etc/selinux/config
# 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 three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted要修改上述文件中的SELINUX=enforcing改成
SELINUX=disabled
然后直接运行setenforce 0
以后重新开机就直接关闭selinux了。
也可以直接使用命令修改上述配置文件
sed -i.bak ‘/SELINUX=/s/enforcing/disabled/g’ /etc/selinux/config
作者:严锋 创建时间:2023-12-07 14:11
最后编辑:严锋 更新时间:2025-11-04 14:01
最后编辑:严锋 更新时间:2025-11-04 14:01