2008/4/30 Glenn Ramsey <glenn@componic.co.nz>:

I just upgraded a spare box, to see if it's safe to upgrade my main
machine, and the upgrade has broken sudo.

When I try to use sudo it says:

sudo: unable to resolve host calc

calc being the hostname of this machine.

How do I fix this? I guess adding the hostname to /etc/hosts would fix
it but I can't do that because sudo is broken. Also I haven't set up a
root account on this machine.

Aside from booting from a rescue disk is there any other way to fix this?

When you firs boot up, pich the rescue option from grub menu and you should drop right to a rootshell, you can edit /etc/hosts from there.

Alternatively;

 press 'e' on the option you normally boot from,
from the next menu choose the line that begins with 'kernel .. '
press 'e' again to edit that line...
delete 'quiet splash' from the end and type 'init=/bin/bash' instead.
When you've done that, press enter then 'b' to boot.

After a few seconds you'll be in bash with a root prompt.

# mount / -o remount,rw

# nano /etc/hosts
make sure there's a line that reads "127.0.1.1 hostname", then save it.

# mount / -o remount,ro

press ctrl-alt-delete and boot normally.