Handy 'nix commands

Some simple commands to help find various things. I always forget them, so I'm writting them down as I go.

Nginx IP check

Count unique IP addresses from the log file; good for checking for abusive bots:

cat /path/to/log_file | grep -o '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | sort -rn | uniq -c | sort -rn | less

Connection check

Count inbound connections per IP.

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Bound ports

Ports being used in a nice grid..

netstat -anltp