首页 > 系统相关 >Linux查看、修改SELinux的状态

Linux查看、修改SELinux的状态

时间:2023-03-15 22:05:10浏览次数:32  
标签:mazhonghua .# 查看 SELinux enforcing SELINUX disabled Linux


SELinux(Security-Enhanced ​​Linux​​) 是美国国家安全局(NSA)对于强制访问控制的实现,是 ​​linux​​历史上最杰出的新安全子系统。但是我们一般都不用它,因为它管的东西太多了,想做安全可以用防火墙等其他措施。 
我们可以通过查看配置文件的命令 cat /etc/selinux/config

[root@mazhonghua ~]# 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 these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

发现SELinux共有3个状态enforcing (执行中)、permissive (不执行但产生警告)、disabled(关闭)。 
我们可以通过修改配置文件来修改SELinux的状态

[root@mazhonghua ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config 
[root@mazhonghua ~]# 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=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

最后我们重启服务器,SELinux状态由enforcing变为disabled 。 
当然,一般我们的Linux都不能重启,我们可以使用这个命令 setenforce 1 临时(重启即失效)设置SELinux 成为enforcing模式(setenforce 0

root@mazhonghua ~]# setenforce 0
[root@mazhonghua ~]# getenforce
Permissive

/usr/sbin/sestatus

[root@mazhonghua ~]# /usr/sbin/sestatus 
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: disabled
Policy version: 24
Policy from config file: targeted


SELinux(Security-Enhanced ​​Linux​​) 是美国国家安全局(NSA)对于强制访问控制的实现,是 ​​linux​​历史上最杰出的新安全子系统。但是我们一般都不用它,因为它管的东西太多了,想做安全可以用防火墙等其他措施。 
我们可以通过查看配置文件的命令 cat /etc/selinux/config

[root@mazhonghua ~]# 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 these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

发现SELinux共有3个状态enforcing (执行中)、permissive (不执行但产生警告)、disabled(关闭)。 
我们可以通过修改配置文件来修改SELinux的状态

[root@mazhonghua ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config 
[root@mazhonghua ~]# 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=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

最后我们重启服务器,SELinux状态由enforcing变为disabled 。 
当然,一般我们的Linux都不能重启,我们可以使用这个命令 setenforce 1 临时(重启即失效)设置SELinux 成为enforcing模式(setenforce 0

root@mazhonghua ~]# setenforce 0
[root@mazhonghua ~]# getenforce
Permissive

/usr/sbin/sestatus

[root@mazhonghua ~]# /usr/sbin/sestatus 
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: disabled
Policy version: 24
Policy from config file: targeted

标签:mazhonghua,.#,查看,SELinux,enforcing,SELINUX,disabled,Linux
From: https://blog.51cto.com/u_6468453/6123564

相关文章

  • hadoop 2.x常用端口及查看方法
    hadoop2.x常用端口及查看方法一、常用端口组件节点默认端口配置用途说明HDFSDataNode50010dfs.datanode.addressdatanode服务端口,用于数据传输HDFSDataNode50075dfs.data......
  • linux目录详解
      /bin存放二进制可执行文件/etc存放系统管理和配置文件/home存放所有用户文件的根目录,是用户主目录的基点,比如用户user的主目录就是/ho......
  • 怎么查看当前环境是生产环境
    首先,需要Environment中的acceptsfiles(参数1),这个方法来判断是是否是参数1中设置好的环境,返回的是Boolean类型。其中参数1的话是通过Profiles中的Of(参数2)的来指定的,......
  • linux安全基线配置
    【shell脚本分享】linux安全基线配置全解析点击关注......
  • 【Azure K8S | AKS】分享从AKS集群的Node中查看日志的方法(/var/log)
    问题描述使用AzureKubernetes服务(AKS),可以通过kubectl连接pod中查看日志,但是如何来查看节点的系统日志呢?如是否有ubuntu系统升级的记录? 问题解答是的,可以进入AKS......
  • linux-screen终端会话后台运行
    screenlinux终端关闭,也不影响终端里命令的正常运行,就需要screen及tmux特点会话恢复多窗口会话共享install&&usedyuminstall-yscreen//状态说明Attached......
  • Pycharm打开项目文件发现项目中的文件夹不见了,但是本地查看文件夹及内容还在
    今天电脑突然重启,开机后,Pycharm打开项目发现项目中的某个文件夹不见了,但是本地查看发现该文件夹及内容还在,就是在pycharm中无法显示,问题排查:本地新建项目发现可以显示项......
  • [Linux]将ArchLinux安装到U盘并保留通用空间
    将ArchLinux安装到U盘并保留通用空间几个月前入门Arch的时候上网搜了不少安装教程,同时由于当时硬盘空间不太够于是就打算安装到U盘上,也因此踩了不少坑。但128G的U盘都拿......
  • Linux内网利用nfs将目录挂载到其它机器
    机器:24.47.155.14/24.47.155.15需求:将24.47.155.15的/data目录挂载到24.47.155.14的/data上1、安装nfs工具(两台)yuminstallnfs-utils2、开启nfs服务(两台)......
  • Linux开机自启动
    Linux系统开机自启动配置(多方案)方案一(以nginx为例):说明:直接使用Linux系统自带开机管理方式(systemctl)。1、在系统服务目录里创建nginx.service文件vi......