How to mount harddrives via label

I followed an outdated tutorial to mount my hardrives in the fstab with their assigned names (like /dev/hda1). I found out the hard way that those names can change at any time, e.g. when plugging the harddrive into a different slot on the controller. I learned that it’s much safer to do this by labelling the harddrives and referencing those labels when mouting them.

First give your harddrive or partition a name:

sudo e2label /dev/sda1 big_mama

Now you can use the label in your /etc/fstab (Add other parameters as needed):

LABEL=big_mama /Volumes/big_mama ext3

An uglier solution would be to reference the drives by their UUIDs but it will make fstab a lot less readable and editing it after a while might get confusing.

The upside of this is: If you hook up a new harddrive to your controller or if you swap them, the system will still mount them into the right directories.

Exploring Domain Information with your Console

Overall dig is an invaluable tool that can help you debug all sorts of DNS related situations, ranging from “Why’s my server not reachable” to “Why does Google Mail not accept my mails” (e.g. when it comes to MX records). Here are some console tricks to dig up some infos about domains.

To find the authorative dns servers for a domain:

dig any example.com

This would tell us that these servers manage this domain:

ns1.dnsserver.com
ns2.dnsserver.com
ns3.dnsserver.com

Now we can find all CNAME and MX records of this domain (no A records!)

dig any example.com @ns1.dnsserver.com

To find out who owns the domain (this might not work, depending on the policy of the registrar):

whois example.com

Finally, you might want to find out some things about an IP address:

To find who the owner of the address is:

whois 123.123.123.123

To find the PTR (or reverse DNS) record:

nslookup 123.123.123.123

How to customize the shell prompt

Depending on your system, you put this into your .bashrc, .bash_login or .profile in your home directory.

export PS1="\[\033[1;34m\]\h\[\033[1;30m\]:\w\[\033[0;30m\]"

The code starts with

\[\033[

followed by one of these colour codes:

Colour Code
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33

and ends with:

m\]

There are some switches which can add some infos to your prompt (current path, date, time, etc.):

\a an ASCII bell character (07)
\d the date in “Weekday Month Date” format (e.g., “Tue May 26”)
\h the hostname up to the first ‘.’
\H the hostname
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following the final slash)
\t the current time in 24_hour HH:MM:SS format
\T the current time in 12_hour HH:MM:SS format
@ the current time in 12_hour am/pm format
\u the username of the current user
\w the current working directory
\W the basename of the current working directory
! the history number of this command
# the command number of this command
$ if the effective UID is 0, a #, otherwise a $

(via mactips.org)

To make folders, files and links coloured when you use ls, put this in one of the above mentioned files:

export LS_OPTIONS="--color=always --human"

Eye to eye with Exim

Sometimes there are messages stuck in the Exim mail queue and sometimes you might wish to look inside them. Exim is a complex beast, but it comes with plenty of tools to help you analyze the current situation.

To see how many mails are stuck in the queue and since when use:

mailq

This will output a list of message IDs; to look inside these messages use for the header

exim4 -Mvc [message-ID]

for the body

exim4 -Mvb[message-ID]

If these don’t work for you, try “exim” or “exim3” instead of “exim4”.

Here are a few more commands (via Florian Fritsch):

Get the mail queue as a table:

mailq | exiqsumm

Get the number of mails in the queue:

exim4 -bpc

Force the delivery of emails that have a local recipient:

exim4 -ql

Find out why a specific mail could not be delivered:

exim4 -v -M [message ID]

Process the queue and send out the emails (if possible):

exim4 -q

Process the queue and send out the emails (verbose mode):

exim4 -qff -v

Send out frozen emails:

exim4 -Mt [message ID]

Delete all frozen emails:

mailq | awk '/frozen/{print "exim4 -Mrm "$3}' | /bin/sh

Delete a specific email from the queue:

exim4 -Mrm [message ID]

Macbook Pro Arrived

Since Apple transitioned to Intel chips I started thinking about bying a Macbook Pro. Professionally I’ve been using Macs off and on and I’ve owned an iPod for quite a while now. I was always impressed by the polish and attention to detail Apple products have. But the price and totally different hardware architecture always held me back from buying a Mac. For all its flaws, I really appreciate the versatility of Windows machines that allows me to work but also game on them. With Bootcamp I hope to get the best of both worlds.