Blog - unix

Setting the timezone in FreeBSD

Wed May 23 19:59:49 BST 2007

Since moving back to the UK I wanted to set my system clock to the correct timezone (ie not Brisbane time). As the last time I had done this was eight months ago, I had forgotten how to do it. A Google search revealed a method that I had not used before but seems to have worked:

cd /etc/
sudo cp /usr/share/zoneinfo/Europe/London localtime
sudo adjkerntz -a



Installing Apache (again)

Fri May 4 17:32:03 EST 2007

The Facebook API looks pretty interesting, and has prompted me to have a look at CGI programming again. The first step in this process is to install Apache on my laptop, as editing code on my webserver in the UK from Australia rapidly becomes tedious due to the lag.

My webserver account uses suexec, so I want to install Apache with that in use. This requires setting the WITHAPACHESUEXEC=yes environment variable before installing the port. Don't install Apache yet though!

I also want to have php4 installed, with the mod_php Apache module. This is done by sudo make config in the lang/php4 directory and choosing the "Install Apache Module" option. Then sudo make install clean installs both php4 with apache13 being installed as a dependency.

Tested the webserver by going to localhost - that worked fine. Tested http://localhost/cgi-bin/test-cgi (one of the default examples installed along with Apache). (...)



More wireless fun and games - DNS

Wed Aug 30 10:39:08 EST 2006

As I mentioned yesterday, connecting to the wireless network is a three stage process: load the kernel module for the wireless card, get a DHCP lease, connect to the VPN, plus the extra step of logging in to a NetCheck account through the web if you want to access things outside Griffith. This works well ... for about half an hour. Then the DHCP lease expires and is renewed, in the process replacing the good nameservers in /etc/resolv.conf (i.e. the ones that can be accessed through the VPN) with the default nameserver for first getting wireless access, which redirects everything the the Griffith Wireless webpage. Fortunately this problem has been solved at [Logging onto a (Microsoft) Wireless VPN using PPTP-Client].

The solution is to edit /etc/dhclient.conf and add the line

prepend domain-name-servers,;

Comment out this line if using wireless outside Griffith.



Wireless FreeBSD and VPN

Tue Aug 29 09:55:10 EST 2006

Back in Oxford connecting my laptop to the physics network was as simple as telling the physics IT staff its MAC address and assuring them that I had the latest Windows Service Pack and antivirus, or in practice that I was running FreeBSD and hence relatively immune to internet nasties.

In Griffith Uni the IT is handled centrally, and the default system specified is Windows. It is possible to connect non-Windows system to the network, but only over the wireless connection. Result: I get to find out how wireless works under FreeBSD. Fortunately one of my new labmates let me use his computer while he was in the lab, so I could do the necessary reseach (read: google).

First hurdle: getting FreeBSD to recognise the wireless card. A quick google search for "FreeBSD linksys WPC45G" and "FreeBSD netgear WG511" (the two wireless cards available at the university shop) found a HOW-TO for the linksys card at [Tao Security



Reference cards

Wed Aug 2 09:51:59 BST 2006

[Quick reference cards] for unix editors such as Vi and Emacs, as well as markup languages.

[unix] [vim]


Program types

Sun Jul 16 11:38:03 BST 2006

Eric Raymond's book "The Art of Unix Programming" is a great explanation of the Unix programming philosophy (and Zen), as well as a guide for writing good programs. In Chapter 11 he discusses a set of common Unix interface Design Patterns, ie how the program interacts with the user. The key points about Unix are that everything is a file, and ideally all data is stored in plain text files. This means that data can be processed using a number of different programs, rather than the specific program that was originally used to produce the data.

The design patterns are:

  • Filter. The program receives data on standard input, does something to it and returns the result to standard output. The user can use shell redirection to read from or write to a file instead of stdin/stdout. Filters can be chained together.
  • Cantrip. Invoke the command and it does something, with no input or output required by the user. (...)

[code] [unix]


I have a lot of papers

Sun Jul 16 11:22:38 BST 2006

Continuing with the moving theme, what to do about the couple of filing cabinet drawers worth of papers I have acquired over the last seven years in Oxford (plus the ones scattered around my room, desk, boxes from previous moves)? As for the books there is a technological solution.

All of the papers from the arXiv can be indexed in a single text file with lines of the form quant-ph/0601012 for example. For ease of entry use abbreviations eg qp0601012, ph0503145 then use a string replace in Vim to convert to the fullform. Then either automated download of the papers in much the same way as the isbn numbers for my books (but put in a delay of several seconds to avoid the rampaging robot trigger), or just the abstract page for each paper and grep out the title and authors to convert into a link. The arXiv isn't going anywhere and is open access, so I'll probably go with the second option and create a links page of papers in my blog. (...)



I have a lot of books...

Sat Jul 15 16:15:21 BST 2006

Moving back to Australia soon. Need to know what books I have and which boxes they are in for packing and possible replacement if any boxes do not arrive. Solution:

  1. Enter the ISBN numbers into a text file as 11 digit strings, one per line. Call this file isbnList.txt
  2. One line shell script:

    cat isbnList.txt | sed -e "s-^-" | xargs -J % curl % | grep "" > booknames.txt</p></li> <li><p>Clean up booknames.txt in Vim to remove the leading and trailing title tags. %s/^\s<title>// and similar for the trailing tag</p></li> <li>paste isbnList.txt booknames.txt > isbnandname. (...)</li> </ol> <p>[<a href="blog/blog_unix/blog_unix.html">unix</a>]</p> <p>[<a href="blog/perm_2006_07_15_161521.html">permalink</a>]</p> </div> <div id="catnav"> <div class="catnavcell"><p><a href="">code</a> (31)</div> <div class="catnavcell"><a href="">cooling</a> (4)</div> <div class="catnavcell"><a href="">erlang</a> (6)</div> <div class="catnavcell"><a href="">ideas</a> (24)</div> <div class="catnavcell"><a href="">lisp</a> (1)</div> <div class="catnavcell"><a href="">me</a> (16)</div> <div class="catnavcell"><a href="">notes</a> (6)</div> <div class="catnavcell"><a href="">ocaml</a> (5)</div> <div class="catnavcell"><a href="">physics</a> (46)</div> <div class="catnavcell"><a href="">politics</a> (7)</div> <div class="catnavcell"><a href="">qo</a> (7)</div> <div class="catnavcell"><a href="">security</a> (2)</div> <div class="catnavcell"><a href="">unix</a> (8)</div> <div class="catnavcell"><a href="">vim</a> (4)</p></div> </div> </div> </div></body> </html>