getenforce -------查看selinux的模式
selinux的配置模式修改
永久修改;
------ll /etc/sysconfig/selinux /etc/selinux/sonfig 查看配置文件和系统日志
------vim /etc/selinux/config
SELINUX=disabled关闭 / permissive启用但不执行 / enforcing启用及执行
------reboot
部署httpd服务
要求:httpd需要读取var/www/html/index.html
-----systemctl stat httpd 开启次服务
-----echo redhat >>index/html
-----mv index.html var/www/html/
-----curl http://localhost
开启selinux
------setenforce 1
-------curl /http://localhost -l
-------ls -ldZ /var/www/html/index.html admin_home_t的安全性上下文
-------ps -elfZ | grep httpd 进程的安全上下文
修改安全性上下文
第一种方法,还原默认值又变回默认值:
-----chocn -t httpd_sys_content_t /test
------chcon --reference=/tmp /test 以/tmp为参照修改/test目录为/tmp
------ll -ldZ /test 修改后查看test
------ll -ldZ /tmp
------restorecon -Rv /test 还原默认值
第二种方法:推荐
-----semanage fcontext -a -t httpd_sys_content_t "/test(/.*)?"修改/test及其子目录下的默认安全性上下文为http_sys_content_t
-----ll -ldZ /test
-----restorecon -Rv /test 还原默认值
-----semanage fcontext -l | grep test
firewalld基础命令
------systemctl stop firewalld 关闭
------systemctl start firewalld 启动
------systemctl enabled firewalld 开机自动启动
------firewall-cmd --state 查看状态
------systemctl status firewalld 查看配置
-----firewall-cmd --reload不影响现有服务及用户连接
----ps -ef | grep firewalld 查看进程
-----firewall-cmd --get-zones 查看所有zone
-----firewall-cmd --get-default-zone 查看默认zone
-----fierwall-cmd --list-all 查看当前zone
-----firewall-cmd --list-all --zone=work 查看zone状态
----firewall-cmd --list-service 查看当前zone默许哪些服务
----ls /usr/lib/firewalld/services/ 查看支持哪些服务
----firewall-cmd --list-ports 查看当前端口状态
------firewall-cmd --query-port=80/tcp 查看具体端口开发状态