查看 SELinux状态及关闭SELinux

xiaoxiao2021-02-28  10

setenforce是Linux的selinux防火墙配置命令 执行setenforce 0 表示关闭selinux防火墙。 setenforce命令是单词set(设置)和enforce(执行)连写,另一个命令getenforce可查看selinux的状态 关闭SELinux的方法:

修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。

如果不想重启系统,使用命令setenforce 0 注: setenforce 1 设置SELinux 成为enforcing模式 setenforce 0 设置SELinux 成为permissive模式

选项与参数: 0 :转成 permissive 宽容模式; 1 :转成 Enforcing 强制模式

SELinux 的启动、关闭与查看 1、并非所有的 Linux distributions 都支持 SELinux 前 SELinux 支持三种模式,分别如下: •enforcing:强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了; •permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用; •disabled:关闭,SELinux 并没有实际运作。 2,查看SELinux的模式 # getenforce Enforcing <==就显示出目前的模式为 Enforcing 3,查看 SELinux 的政策 (Policy)? [root@master oracle]# sestatus SELinux status: enabled <==是否启动 SELinux SELinuxfs mount: /selinux <==SELinux的相关文件资料挂载点 Current mode: enforcing <==目前的模式 Mode from config file: enforcing <==设定档指定的模式 Policy version: 21 Policy from config file: targeted <==目前的政策为何?

在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux

4,通过配置文件调整SELinux的参数 [root@www ~]# vi /etc/selinux/config SELINUX=enforcing <==调整 enforcing|disabled|permissive SELINUXTYPE=targeted <==目前仅有 targeted 与 strict

查看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

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

SELinux status:                 enabled            

SELinuxfs mount:                /sys/fs/selinux SELinux root directory:         /etc/selinux Loaded policy name:             targeted Current mode:                   enforcing Mode from config file:          enforcing Policy MLS status:              enabled Policy deny_unknown status:     allowed Max kernel policy version:      28 Process contexts: Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 Init context:                   system_u:system_r:init_t:s0 File contexts: Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0 /etc/passwd                     system_u:object_r:passwd_file_t:s0 /etc/shadow                     system_u:object_r:shadow_t:s0 /bin/bash                       system_u:object_r:shell_exec_t:s0 /bin/login                      system_u:object_r:login_exec_t:s0 /bin/sh                         system_u:object_r:bin_t:s0 -> system_u:object_r:shell_exec_t:s0 /sbin/agetty                    system_u:object_r:getty_exec_t:s0 /sbin/init                      system_u:object_r:bin_t:s0 -> system_u:object_r:init_exec_t:s0 /usr/sbin/sshd                  system_u:object_r:sshd_exec_t:s0

转载请注明原文地址: https://www.6miu.com/read-200030.html

最新回复(0)