selinux的开启和关闭方法

关闭SELinux的方法:
修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
如果不想重启系统,使用命令setenforce 0

/etc/init.d/network restart


注:
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux

#---------------------------------------------------------------
查看selinux状态:
/usr/bin/setstatus -v
如下:
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   permissive
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        targeted

getenforce/setenforce查看和设置SELinux的当前工作模式
#-----------------------------------------------------------------------
   发现服务一启动,马上停止,在网上查找资料,找到安装时要先禁用SELinux,再安装MySQL,步骤是:

1. 关闭SELinux,重启系统;
2. 安装MySQL(MySQL server应该可以启动了);
3. 启用SELinux,重启系统,之后MySQL server就可以正常启动了。

   启用禁用SELinux的方法是:

   vi /etc/selinux/config(也有人说是/etc/sysconfig/selinux文件,其实两个之间是链接关系,随便改其中一个,另一个也改了)

   SELINUX=disable 禁用SeLinux

   SELINUX=enforcing 启用SeLinux


***************************************************************************

问题很简单:我把vsftpd.conf都配置好了,user_list也配置了,但是一直连接不过去,一直报错。



解决方法:我在网上不断找资料,问朋友,最终找到问题的原因了:selinux的问题,应该把这东东“关闭”



下面我给大家大概讲解下selinux配置与原理,希望能帮助一些朋友解决类似的问题



Security-Enhanced Linux (SELinux)是一个集成到2.6x内核中的、使用linux安全模块(LSM)的安全体系结构,它是美国国家安全局(NSA)和SELinux社区的一个项目。

概述:

SELinux提供了一个构建到linux内核中的、灵活的强制访问控制系统。在标准的linux自主访问控制中,一个应用程序或进程以一个用户的身份(UID或SUID)运行,它们对目标(如文件、套接和其他进程)有特定的访问权限。而运行一个强制访问控制内核可以防止恶性程序或有设计漏洞的程序对系统进行破坏。

配置文件:

SELinux的主配置文件是/etc/sysconfig/selinux,其实/etc/sysconfig/selinux只是一个符号链接,相当于windows里的快捷方式,它真的配置文件在位置是:/etc/selinux/config。运行more /etc/selinux/config可以看到

[root@os ~]# more /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 - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

SELINUX 这定义在一个系统上SELinux最高级别的状态

enforcing 强制模式,SELinux安全政策被强制执行

permissive 兼容模式,SELinux系统输出警告信息,但不强制执行安全政策

disabled 禁用模式,SELinux被完全终止



SELINUXTYPE  指定那个政策SELinux应该被强制执行

targeted 只有选定的网络守护进程会得到保护,一般保护进程有:dhcpd、httpd(apache)、named、nscd、ntpd、portmap、snmpd、squid和syslogd

strict  指对所有的进行都强制保护



关闭SELinux方法

1、修改主配置文件,将

SELINUX=permissive改为SELINUX=permissive或者disabled

值得注意的是:修改主配置文件要重启后才能生效

2、使用命令来关闭SELINUX(可以不用重启服务器)

setenforce 0

这命令并不是关闭SELINUX而是将其改为兼容模式(permissive)

setenforce 1

将其改为强制安全模式(permissive)

猜你喜欢

转载自tianyihuyidao9.iteye.com/blog/1617948
今日推荐