Custom Scripts
To kill Dead process
for i in `ps ax | grep D | awk {’print $1′}`;do kill -9 $(cat /proc/${i}/status | grep PPid | awk {’print $2′});done
To kill Zombie process
for i in `ps ax | grep Z | awk {’print $1′}`;do kill -9 $(cat /proc/${i}/status | grep PPid | awk {’print $2′});done
To find ddos attack
netstat -an |grep 80
netstat -plan|grep :80|awk {’print $5′}|cut -d: -f 1|sort|uniq -c|sort -nk 1
netstat -plan|grep :25|awk {’print $5′}|cut -d: -f 1|sort|uniq -c|sort -nk 1
watch -n 5 ‘w; ls -alS /usr/local/apache/domlogs/ ‘
Top memory consuming processes
ps aux | head -1;ps aux –no-headers| sort -rn +3 | head
Number of exim connections
tail -1000 /var/log/exim_mainlog |grep ‘\[' |cut -d[ -f2 |cut -d] -f1|sort -n |uniq -c |sort -n
To find cppop attack
tail -1000 /var/log/maillog | grep host= | cut -d= -f2| cut -d” ” -f1|sort -n |uniq -c |sort -n
To find number of httpd connections
netstat -plan|grep :80|awk {’print $5′}|cut -d: -f 1|sort|uniq -c|sort -nk 1
or
netstat -pan | sort +4 | grep TIME_WAIT | awk ‘{print $5}’ | sed -e s/’:.*’//g | sort | uniq -c | sort -k 1 -nr | head -n 20
Script to change permission of files 777 to 644
find /home/*/public_html/ -type d -perm 777 -exec chmod 755 {} \;>/dev/null 2>&1

0 comments:
Post a Comment