Forget / forgot / cannot remember root password

On a FreeBSD server

1. reboot server
2. choose to boot into single user mode
3. mount -o rw <root partition> e.g. mount -o rw /
4. passwd <root account> e.g. passwd root
5. mount -o ro <root partition> e.g. mount -o ro /
6. reboot server again

Voila !!!

How to dig SRV record after creating it in DNS

dig <record type> <host.name>

e.g dig SRV _someservice._port.hostname.domainame.com.my OR dig SRV _https._ICMP.host.takizo.com

ls & rm with regular expression

e.g. rm -rf backup-20070[8-9]-*

would delete :

  • backup-200708-morning
  • backup-200708-evening
  • backup-200709-night
  • backup-200709-latenight

but not :

  • backup-200706-morning
  • backup-200707-afternoon
  • backup-200711-midnight

e.g. ls backup-20070[1-9] would list all backup starting from January to September but leave October, November & December out, of year 2007.

sed with multiple criteria

sed -e 1d -e 50d -e ‘/junks/d’

would remove first and 50th line & any line(s) with the word “junks”.

update 20080821 :

sed -e ‘/^$/d’

would remove every empty line

freebsd port update, monitor outdated port with portsnap

we have about 15 freebsd servers with us, ranging from freebsd 4.7 to freebsd 7. most of the server need to be patched regularly, except servers that are not accessible from public network. one of the method we use to monitor outdated port is using portsnap cron, it update the port tree base on the date/time you configured on crontab, and when there is any port is outdated, it will notify us through email from system message.

setting up port tree update on cron

fire up your crontab with crontab -e and add this line;

0 7 * * * portsnap -I cron update && pkg_version -vIL=

this will update the port tree every morning 7am and if there is any output from the command pkg_version -vIL=, it will send an email to system root.

alias root to your email address

if you wish to receive the notification through your email, on /etc/aliases file, alias root to your_email_address, remember to run newaliases command after update the file.

Email notification from different servers.

Port that outdated and need to be upgraded.