Skip to content


Apache Log Grepping

Nothing beats a full stats package, but with a little grepping and a logfile and we can figure out some quick statistics.

Get only hits coming from Google.com/search:

grep 'google.com/search' access_log | head -1

Extract only the referrer field:

grep 'google.com/search' access_log | head -1 | awk '{print $11}'

Get the search terms only:

grep 'google.com/search' access_log | \
  head -1 | \
  awk '{print $11}' | \
  cut -d\? -f2 | cut -d\& -f1 | \
  sed 's/+/ /g;s/%22/"/g;s/q=//'

Here’s a little script that puts it all together. It finds the unique search terms, cleans out the trash, sorts them and list the top twenty five in order of descending hit count.

#!/bin/sh
LOG="/var/logs/httpd/access_log"
grep 'google.com/search' $LOG | \
  awk '{print $11}' | \
  cut -d\? -f2 | cut -d\& -f1 | \
  sed 's/+/ /g;s/%22/"/g;s/q=//' | \
  sed 's/%[0-9a-fA-F][0-9a-fA-F]/ /g;s/"//g' | \
  grep -v '=' | sort | uniq -c | sort -rn | head -25

To see them all remove the | head -25 statement at the end of the command.

Thanks to an article at Linux Journal for the examples.

Popularity: 1% [?]

Posted in Snippets.


Find setuid root Files

Find all setuid / setgid files owned by root:

find / -user root -type f \( -perm -4000 -o -perm -2000 \) -exec ls -ld '{}' \;

Find all setuid / setgid files owned by any user:

find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls -ld '{}' \;

Popularity: 1% [?]

Posted in Snippets.

Tagged with , .


Debugging HTTP Headers with cURL

curl -I http://damonparker.org

More info on cURL

Popularity: 1% [?]

Posted in Snippets.

Tagged with .


Back

After nearly two years with not much to say, I decided to pick up the blog again. It was a long and winding journey, this time in between. Maybe more on that later.

I should be updating the pages of the blog with current info about myself and my projects over the next few weeks.

As always, the shop is open for any sysadmin or development projects.

Popularity: 1% [?]

Posted in General.


DNS, Lookupd and OS X

Pre-Leopard the command to force OS X to flush and reload it’s DNS cache was:

sudo lookupd -flushcache

In Leopard, lookupd no longer exists. Instead force a DNS cache refresh with:

sudo dscacheutil -flushcache

Popularity: 92% [?]

Posted in Apple / Mac.


OSX Scrollbars Top and Bottom

In Terminal:

defaults write "Apple Global Domain" AppleScrollBarVariant DoubleBoth

Popularity: 85% [?]

Posted in Snippets.