第十周
1、编写脚本selinux.sh,实现开启或禁用SELinux功能
#!/bin/bash [ $# -ne 1 ] && echo "Usage:bash $0 <off|on>" && exit 10 if [ "$1" = "on" ];then sed -i s/SELINUX=disabled/SELINUX=enforcing/ /etc/selinux/config [ $? -eq 0 ] && echo "SELinux is on" /sbin/setenforce 1 elif [ "$1" = "off" ];then sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config [ $? -eq 0 ] && echo "SELinux is off " /sbin/setenforce 0 else echo "Error!Please input <on|off>" exit 20
验证:
[ scripts43]#getenforce
Enforcing
[ scripts43]#sh selinux.sh
Usage:bash selinux.sh <off|on>
[ scripts43]#sh selinux.sh off
SELinux is off
[ scripts43]#sh selinux.sh on
SELinux is on
2、统计/etc/fstab文件中每个文件系统类型出现的次数
[ scripts43]#cat /etc/fstab | awk ‘/^UUID/{sys[$3]++}END{for(i in sys){print i,sys[i]}}‘ swap 2 xfs 4
3、提取出字符串%9&Bdh7dq+YVixp3vpw中的所有数字
[ scripts43]]#echo "%9&Bdh7dq+YVixp3vpw" |tr -dc [:digit:]`
4、解决DOS 攻基生产案例:根据web日志或者或者网络连接数,监控当某个IP?并发连接数或者短时内PV达到100,即调用防火墙命令封掉对应的IP,监控频?率每隔5分钟。防火墙命令为:iptables?-A?INPUT?-s?IP?-j?REJECT
[ scripts43]#awk ‘{ip[$1]++}END{for(i in ip) {if(ip[i]>99){system("iptables -A INPUT -s "i" -j REJECT")}}}‘ /var/log/httpd/access_log
架构班的小伙伴看这里:
1、使用docker-compose制作nginx+php-fpm,mysql,wordpress镜像,并管理启动,实现wordpress的访问
2、使用ansible进行K8s初始化安装配置。