分享好友 系统运维首页 频道列表

查看SELinux状态&关闭SELinux

Linux系统  2016-12-01 15:150

1. 查看SELinux状态

1.1 getenforce

  • getenforce 命令是单词get(获取)和enforce(执行)连写,可查看selinux状态,与setenforce命令相反。
  • setenforce命令则是单词set(设置)和enforce(执行)连写,用于设置selinux防火墙状态,如: setenforce 0 用于关闭selinux防火墙,但重启后失效

    [root@localhost ~]# getenforce
    Enforcing

1.2 /usr/sbin/sestatus

Current mode表示当前selinux防火墙的安全策略

[root@localhost ~]# /usr/sbin/sestatus
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

SELinux status:selinux防火墙的状态,enabled表示启用selinux防火墙

Current mode: selinux防火墙当前的安全策略,enforcing 表示强

2. 关闭SELinux

2.1 临时关闭

setenforce 0:用于关闭selinux防火墙,但重启后失效。

[root@localhost ~]# setenforce 0
[root@localhost ~]# /usr/sbin/sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

2.1 永久关闭

修改selinux的配置文件,重启后生效。

打开 selinux 配置文件

[root@localhost ~]# vim /etc/selinux/config

修改 selinux 配置文件

将SELINUX=enforcing改为SELINUX=disabled,保存后退出

# 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 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防火墙的安全策略仍为Enforcing,配置文件并未生效。

[root@localhost ~]# getenforce
Enforcing

重启

[root@localhost ~]# reboot

验证

[root@localhost ~]# /usr/sbin/sestatus
SELinux status:                 disabled

[root@localhost ~]# getenforce
Disabled

本文永久更新链接地址 http://www.linuxidc.com/Linux/2016-11/137723.htm

查看更多关于【Linux系统】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
在CentOS上为Docker开启SELinux
div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, u

0评论2023-02-09512

?第五周作业
1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;[root@localhost ~]# grep-E ^[[:space:]]+ /boot/grub/grub.conf root (hd0,0)kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS.UTF-8 rd_NO_MD rd_LVM_L

0评论2017-02-05452

sed 替换、修改链接文件注意问题
sed 替换、修改链接文件注意问题#系统与版本[root@localhost~]# cat /etc/redhat-releaseCentOS release 6.8 (Final)[root@localhost~]# sed --versionGNU sed version 4.2.1Copyright (C) 2009 Free Software Foundation, Inc.This is free software; see th

0评论2016-12-23204

初识SElinux
一、SElinux(Secure Enhanced Linux):安全增强的LinuxSElinux是一个在内核中实践的强制访问控制(MAC)安全性机制,由美国国家安全局NSA(The National Security Agency)和SCC(SecureComputing Corporation的)开发的针对计算机基础结构安全开发的一个全

0评论2016-09-18121

SElinux
selinux 配置文件 修改就要重启targeted:用来保护常见的网路服务,仅有限进程受到selinux控制,只监控容易被入侵的进程。targeted 慢慢完善的法律 系统默认使用targetedCENTOS6CENTOS7 ZAIZHEGEWENJIAN或者 cat /etc/sysconfig/selinuxSELINUX一切皆对象objec

0评论2016-09-1469

关闭selinux(防火墙)方法分享
默认装完CentOS,Selinux是打开的,这个你基本都是需要关闭,查看当前selinux的状态后,就可以按以下方法关闭selnux了

0评论2015-07-15131

更多推荐