标签:计划任务 取出 set use rar uuid dev dos txt
1、编写脚本selinux.sh,实现开启或禁用SELinux功能#!/bin/bash
[ $# -ne 1 ] && {
echo ‘Useage: selinux on | off | enable | disable‘
exit
}
case $1 in
on)
setenforce 1 && echo "SELinux has been turn on temporary."
;;
off)
setenforce 0 && echo "SELinux has been turn off temporary."
;;
enable)
setenforce 1
sed -i ‘s/SELINUX=disabled/SELINUX=enforcing/‘ /etc/selinux/config
echo "SELinux has been enabled,you need reboot mechine to make it work."
;;
disable)
setenforce 0
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
echo "SELinux has been disabled,you need reboot mechine to make it work."
;;
*)
echo ‘Useage: selinux on | off | enable | disable‘
esac
# 第一种方法
egrep -v ‘^#|^$‘ /etc/fstab | awk ‘{print $3}‘ | sort -r | uniq -c
# 第二种方法
awk -F" " ‘/^UUID|^\/dev/{print $3}‘ /etc/fstab | uniq -c | sort -r
echo "Yd$C@M05MB%9&Bdh7dq+YVixp3vpw" | awk ‘{gsub(/[^0-9]/,""); print $0}‘
# blockip.sh
#! /bin/bash
ss -tan | awk -F " +|:" ‘/ESTAB/{ip[$(NF-2)]++}END{for(i in ip)if(ip[i]>99) print i}‘ > /tmp/BlockIP.log
while read IP;do
iptables -A INPUT -j REJECT -s $IP
echo "`date +‘%F %T‘` $IP reject" >> /tmp/BlockList.txt
done < /tmp/BlockIP.log
# 给脚本添加执行权限
chmod u+x blockip.sh
# 添加计划任务
echo ‘* */12 * * 1-5 /root/blockip.sh‘ >> /var/spool/cron/root
标签:计划任务 取出 set use rar uuid dev dos txt
原文地址:https://blog.51cto.com/14920534/2575381