QiHsMing 2020-06-28
[ scripts]# cat selinux.sh #!/bin/bash . /etc/init.d/functions STATUS=`getenforce` start(){ [ $STATUS != Disabled ] && { setenforce 1;echo "Selinux is already started";return 10; } sed -i ‘s/SELINUX=disabled/SELINUX=enforcing/‘ /etc/selinux/config action "starting selinux ..." echo "You need to restart the system for the changes to take effect." } stop(){ [ $STATUS = Disabled ] && { echo "Selinux is already stopped";return 20; } sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config action "stopping selinux ..." echo "You need to restart the system for the changes to take effect." echo "You can also use ‘setenforce 0‘ to turn off selinux temporarily" } status(){ getenforce } case $* in start) start ;; stop) stop ;; status) status ;; *) echo "Usage:$0 {start|stop|status}" exit 100 ;; esac # 执行结果 [ scripts]# ./selinux.sh status Disabled [ scripts]# ./selinux.sh start starting selinux ... [ OK ] You need to restart the system for the changes to take effect. [ scripts]# ./selinux.sh stop Selinux is already stopped [ scripts]#./selinux.sh status Enforcing [ scripts]#./selinux.sh stop stopping selinux ... [ OK ] You need to restart the system for the changes to take effect. You can also use ‘setenforce 0‘ to turn off selinux temporarily
[ ~]# awk ‘/^[^# ]/{fsys[$3]++}END{for(n in fsys)print n,fsys[n]}‘ /etc/fstab swap 1 ext4 1 xfs 3
[ ~]# echo "%9&Bdh7dq+YVixp3vpw" | awk -F "" ‘{for(n=1;n<=NF;n++){if($n ~ /[0-9]/)print $n}}‘ 0 5 9 7 3 [ ~]# echo "%9&Bdh7dq+YVixp3vpw" | tr -dc "[0-9]" 05973[ ~]#
[ ~]# crontab -l */5 * * * * /usr/bin/awk ‘{IP[$1]++}END{for(n in IP){if(IP[n]>100)system("/usr/sbin/iptables -A INPUT -s " n " -j REJECT")}}‘ /var/log/httpd/access_log