Redirecting with Apache’s .htaccess • 04 Jul 2007
When you migrate web sites from one place to another, and the URLS change, you don’t want to lose visitors that still use the old links. If your ‘old’ website ran on Apache, you can use its mod_alias/mod_rewrite functionality to automatically redirect to the new URL. This involves adding redirect rules to the .htaccess file in the base folder of the redirects. Some examples:
Convert Bind DNS zone into PTR records • 15 Jun 2005
The following script I made in order to convert the forward DNS records in a /var/named/db.[domain] file into the correct format for a reverse DNS db.[subnet prefix] file. `` #!/bin/sh (…) DNSROOT=/var/named PREFIX=$1 DOMAIN=$2 shift 2 DNSPRE=$DNSROOT/db.$PREFIX DNSDOM=$DNSROOT/db.$DOMAIN echo “; save this in $DNSPRE” ( if [ -f $DNSDOM ] ; then cat $DNSDOM | grep $PREFIX | grep -w “A” | sed “s/$PREFIX.*//g” | gawk “BEGIN {OFS = “t” ;} {print $4,”IN”,”PTR”,$1 “.$DOMAIN.”,”;; FROM basename $DNSDOM” }” fi</p> if [ -f $DNSPRE ] ; then cat $DNSPRE | grep -w "PTR" | gawk "BEGIN {OFS = "t" ;} {print...
Installing NTP (time synchronisation) • 19 May 2005
Set timezone (optional)
create symbolical link from /usr/share/zoneinfo/... to /etc/localtime:
ln -sf /usr/share/zoneinfo/Europe/Brussels /etc/localtime
Perl HTML scraping part #1 • 21 Jan 2005
Here we are, back at the scene of the crime. Yes, I know it’s been a while. And the task of the day is:
Estimate # of lines in a log file • 21 Oct 2004
Let’s say you need an (approximate) count of the number of lines in a huge file. The most obvious way of calculating this would be using wc, but this actually can be quite slow:
> time wc -l /var/log/squid/access.log
2812824 /var/log/squid/access.log
real 0m43.988s
# (counting is done at 64.000 lines/sec)
Squid: list top X referers • 19 Oct 2004
If your Squid server logs the referers of its request (i.e.
you’ve configured squid-cache with --enable-referer-log before compiling and
you’ve included a referer_log /var/log/squid/referer.log in your squid.conf file),
you can easily show top 50 of most popular referers with a simple Bourne shell:
#!/bin/bash
Redhat versions: what am I running? • 19 Oct 2004
If you manage multiple RedHat servers, or if you just stumble on a Linux server, and you have no idea what kind of machine it is, nor what the version of the OS is, try the following commands: