Tuesday, September 30, 2008

Ubuntu: Unable to Resolve Host and /etc/hosts.

Ran into an interesting problem on my laptop running Ubuntu 8.04. After starting her up, there was a huge delay everytime I tried to run a command from a terminal or a simple app. Turns out I needed to edit my /etc/hosts as it was inadvertently changed.

Trying to sudo produced:
$ sudo -s -H
sudo: unable to resolve host prystasj-laptop
[sudo] password for prystasj:
root@prystasj-laptop:/home/prystasj/tmp# whoami
My /etc/hosts file at this point:
$ cat /etc/hosts localhost dell-desktop.example.com dell-desktop

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I needed to add my hostname to the file at the end of the first line.
Afterwhich, everything went back to normal: localhost prystasj-laptop dell-desktop.example.com dell-desktop
Would be curious to know why this would have an affect when trying to run apps like gvim that wouldn't seem to require internet access.