Linux查看、修改SELinux的状态

Linux系统
1052
linux
linux 举报
2020-06-03

SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统。但是我们一般都不用它,因为它管的东西太多了,想做安全可以用防火墙等其他措施。

我们可以通过查看配置文件的命令 cat /etc/selinux/config 来查看状态,

[root@lill ~]# 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 

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

发现SELinux共有3个状态enforcing (执行中)、permissive (不执行但产生警告)、disabled(关闭)。

我们可以通过修改配置文件来修改SELinux的状态

[root@lill ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config 

[root@lill ~]# 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 

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

最后我们重启服务器,SELinux状态由enforcing变为disabled 。

当然,一般我们的Linux都不能重启,我们可以使用这个命令 setenforce 1 临时(重启即失效)设置SELinux 成为enforcing模式(setenforce 0 设置SELinux 成为permissive模式),用getenforce这个命令来检查。

root@lill ~]# setenforce 0

[root@lill ~]# getenforce 

Permissive

    1

    2

    3

我们还可以用 /usr/sbin/sestatus 命令来查看SELinux的状态。

[root@lill ~]# /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


倒序看帖 只看楼主
热点关注
postfix下过滤垃圾邮件的有效方法
shell脚本每行后面多了一个^M的原因和解决办法
定时检测服务,检测down掉后重启。系统检测到DMSERVER运行正常
挂载磁盘的时候遇到一个问题,挂载完磁盘之后重启服务器挂载的盘丢失了.
中标麒麟系统Your trial is EXPIRED and no VALID licens
termux 开启ssh并用用户名和密码登陆
组成共享库的目标文件和一般的目标文件有所不同,在编译时要加-fPIC和-share选项,例如:
gcc指定链接库路径后还是找不到库文件
./configure -build,-host,-target设置
关于Linux系统中configure中build,target,host中的若干问题
不用单独编译gmp、mpfr和mpc三个包,放在gcc源码下面一起编译
安装最新版本的GCC编译器(./configure执行编译报错 C++ compiler too old)
在后台用进程名运行bash脚本
shell参数判断
postfix过滤规则的几个关键规则