selinux(实验环境:redhat7.0)
1.查看selinux上下文# ls -lZ
# ls -ldZ/tmp/
# ps auxZ 查看进程的上下文
# semanage port--list查看端口的上下文类型
# semanage fcontext --list 查看所有目录上下文
2.selinux的打开与关闭
setenforcing 1|0 SELinux 临时开启或关闭
getenforce 查看当前SELinux的状态
注意:编辑/etc/selinux/config永久生效,从disabled 调整为其它状态,必须要重启系统才会生效
3.修改上下文
# semanage fcontext -a -t httpd_sys_content_t "/custom(/.*)?"
# restorecon -Rv /custom/ 设置完上下文是不生效的,必须执行恢复上下文
注:/var/www/html目录的上下文是httpd_sys_content_t,在配置文件正确的情况下,如果要将/custom目录改为httpd服务的根目录,则/custom目录可以参照/var/www/html/目录修改
4.布尔值
# getsebool -a 查看所有的布尔值信息
# setsebool -P httpd_enable_homedirs on -P:设置Bool值永久生效
5.selinux端口上下文
#semanage port --list 查看端口的上下文类型
#semanage port -a -t ssh_port_t -p tcp 2222 增加2222端口为ssh_port_t类型
补充:若出现selinux问题也可以参考/var/log/message里的提示信息
页:
[1]