一. 3种模式:
enforcing 强制,发现越权既拦截
permissive 放行,发现服务越权警告,不拦截
disabled 对于越权行为不拦截不警告,相当与关闭selinux
修改位置 vi /etc/selinux/config
将 SELINUX=3种模式之一即可
example, SELINUX=enforcing
二. 状态查询、生效、及临时更改
查询使用 getenforce
永久生效需要修改 1中的配置文件并reboot
临时修改 ,适用于配置文件为enforing,但是想测试用临时开关检验配置是否正确,
setenforce 0 #由enforcing 变为 permissive
setenforce 1 #由permissive 变为enforcing
三、安全上下文
查看安全上下文使用 ls 的-Z参数
-Z, --context
Display security context so it fits on most displays. Displays only mode, user, group, security context and file name.
[root@bogon ~]# ls -Zd /home/wwwroot/
drwxr-xr-x. root root system_u:object_r:user_home_dir_t:s0 /home/wwwroot/
[root@bogon ~]# ls -Zd /var/www/html
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html
下面需要使用semanage命令---未完待续
semanage 用法:
1. 添加http端口, 默认selinux不允许更改默认的http端口
查看selinux的端口
[root@moc1 ~]# semanage port -l | grep http
http_cache_port_t tcp 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 81, 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
#添加端口
[root@moc1 ~]# semanage port -a -t http_port_t -p tcp 84