Last active
August 29, 2015 14:06
-
-
Save innesm4/409684832d74d529b95b to your computer and use it in GitHub Desktop.
Useful Server Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check which IPs are hitting a server | |
netstat -plant | awk '$4~/:80$/{print$5}' | awk -F: '{print$(NF-1)}' | sort | uniq -c | sort -nr | head | |
# Apache Report | |
curl -skL apachebuddy.pl | perl | |
# Last 200 commands of error log | |
tail -n 200 /var/log/apache2/error.log | |
# Memory / Max Clients | |
echo Processors -- `grep proc /proc/cpuinfo | wc -l`; echo -e Memory "\t " -- `free -m | grep Mem | awk '{print $2, "MB"}'`; ps -H h -ylC apache | perl -lane '$s+=$F[7];$i++;END{printf"Avg %mem / Apache process = %.1fMB\n",$s/$i/1024}' ; echo ""; grep -i maxclients /etc/apache2/apache2.conf | grep -v ^# | head -1 | awk '{print $1, "is set to --", $2}'; echo ""; echo "Current connections :"; pstree -G | grep apache; echo ""; echo "IPs conneting now :"; netstat -ant | grep \:80 | egrep "ESTABLISHED|SYN_RECV" | awk '{ print $5 }' | sed -e 's/\:\:ffff\://g' | awk -F: '{print $1}' | sort | uniq -c | sort -nr |awk '{print $1 " "$2}' | head ; echo -e "\nErrors from apache logs: "; grep -i maxclients /var/log/apache2/error.log; echo -e "\nDisk space Status :"; df -h /; | |
#Fix Shellshock | |
mkdir src | |
cd src | |
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz | |
#download all patches | |
for i in $(seq -f "%03g" 0 26); do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done | |
tar zxvf bash-4.3.tar.gz | |
cd bash-4.3 | |
#apply all patches | |
for i in $(seq -f "%03g" 0 26);do patch -p0 < ../bash43-$i; done | |
#build and install | |
./configure && make && make install | |
cd .. | |
cd .. | |
rm -r src | |
# Fix Offending key in ~/.ssh/known_hosts file where NUMBER is Offending Key | |
perl -pi -e 's/\Q$_// if ($. == NUMBER);' ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment