Printing previous dates with the FreeBSD date utility

In a previous post, I described how to get the date for a day in the past. This method unfortunately doesn’t work on FreeBSD hosts, since FreeBSD doesn’t come with the GNU date utility. As an alternative to GNU date, you can pass a time value to the date utilities “-v” option to print a date in the past:

$ date -v-2d
Mon Jan 1 13:02:57 EST 2007

I think I prefer the GNU date syntax, but this seems to work pretty well.

Managing FreeBSD ports

I was reading through this months SysAdmin magazine, and came across Richard Bejtlich’s article “Keeping FreeBSD Up to Date.” This article was well timed, since I decided to migrate my laptop from Ubuntu Linux to FreeBSD 6.0. One hurdle in moving to any new Operating System is application and system patch management. Since I haven’t used FreeBSD since release 4.X, I needed to get up to speed on how FreeBSD handled system and application updates. Richard’s article mentions several tools that can be used to keep systems up to date, but one that caught my eye was Colin Pervical’s portsnap utility. This nifty little utility allows you to download compressed ports snapshots, and apply them to /usr/ports. Since this utility looked super cool, I decided to test it out on my new box.

To get started with portsnap, you will need to run portsnap with the “fetch” option. this will snag the latest snapshot from the SERVERNAME defined in /etc/portsnap.conf, and place the files in /var/db/portsnap:

$ portsnap fetch

Once a snapshot finishes downloading, the “extract” option can be used to merge the snapshot into /usr/ports:

$ portsnap extract

This will extract the compressed snapshot into /usr/ports. Once the extraction process completes, the typical processes can be used to build applications (e.g., make or portsupdate). The portsnap(8) manual page mentions that the extract command should only be used to initialize a portsnap-managed ports tree, and subsequent updates should use the portsnap “update” option. If you get a chance, I highly recommend reading Richard’s article. He is a very talented writer, and provides some awesome examples!