第十週

一、編寫腳本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

驗證:
[root@centos7 scripts43]#getenforce
Enforcing
[root@centos7 scripts43]#sh selinux.sh
Usage:bash selinux.sh <off|on>
[root@centos7 scripts43]#sh selinux.sh off
SELinux is off
[root@centos7 scripts43]#sh selinux.sh on
SELinux is onphp

第十週

二、統計/etc/fstab文件中每一個文件系統類型出現的次數

[root@centos7 scripts43]#cat /etc/fstab | awk '/^UUID/{sys[$3]++}END{for(i in sys){print i,sys[i]}}'
swap 2
xfs 4

第十週

三、提取出字符串Yd$C@M05MB%9&Bdh7dq+YVixp3vpw中的全部數字

[root@centos7 scripts43]]#echo "Yd$C@M05MB%9&Bdh7dq+YVixp3vpw" |tr -dc [:digit:]`
第十週mysql

四、解決DOS 攻基生產案例:根據web日誌或者或者網絡鏈接數,監控當某個IP 併發鏈接數或者短時內PV達到100,即調用防火牆命令封掉對應的IP,監控頻 率每隔5分鐘。防火牆命令爲:iptables -A INPUT -s IP -j REJECT

[root@centos7 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_loglinux

架構班的小夥伴看這裏:nginx

一、使用docker-compose製做nginx+php-fpm,mysql,wordpress鏡像,並管理啓動,實現wordpress的訪問git

二、使用ansible進行K8s初始化安裝配置。web

相關文章
相關標籤/搜索