Showing posts from June, 2014

Setting up the hostname in Ubuntu

Most people recommend setting up the hostname on a Linux box so that:

1) running 'hostname' returns the short name (i.e. myhost)
2) running 'hostname -f' returns the FQDN (i.e.
3) running 'hostname -d' returns the domain name (i.e

After experimenting a bit and also finding this helpful Server Fault post, here's what we did to achieve this (we did it via Chef recipes, but it amounts to the same thing):

make sure we have the short name in /etc/hostname:myhost

(also run 'hostname myhost' at the command line)
make sure we have the FQDN as the first entry associated with the IP of the server in /etc/hosts: myhost
make sure we have the domain name set up as the search domain in /etc/resolv.conf:search

Reboot the box when you're done to make sure all of this survives reboots.