set FQDN for hostname

Luis Paulo luis.barbas at
Sat Nov 6 16:58:32 UTC 2010

On Sat, Nov 6, 2010 at 10:29, Tom H <tomh0665 at> wrote:
> Assuming
> cat /etc/network/interfaces
> auto lo
> iface lo inet loopback
> auto eth0
> iface eth0 inet dncp
> and
> cat /etc/hosts
>   localhost.localdomain   localhost
>   thufir.hawat   thufir
> If "/etc/hostname" is empty or non-existent, "hostname" and "hostname
> --short" will return "localhost", "hostname --long" will return
> "localhost.localdomain", and "hostname --domain" will return
> "localdomain".
> If "cat /etc/hostname" returns "thufir",  "hostname" and "hostname
> --short" will return "thufir", "hostname --long" will return
> "thufir.hawat", and "hostname --domain" will return "hawat".
> If "cat /etc/hostname" returns "thufir.hawat",  "hostname" and
> "hostname --long" will return "thufir.hawat", "hostname --short" will
> return "thufir", and "hostname --domain" will return "hawat".
> Having two "" is strange - and possibly "illegal".
> The "" entry in Debian/Ubuntu's "/etc/hosts" is a Debian hack
> that was prompted (IIRC; I read a long time ago a some debian-devel
> posts on this topic) by a desire not to have a box's
> systemname/hostname be an alias of "localhost.localdomain" or
> "localhost". I've forgotten the reason for this desire!
> --

Right, the /etc/hostname file

>From man hostname
"The host name is usually set once at system startup in
/etc/init.d/ (normally by reading the contents of a file
which contains the host name, e.g.  /etc/hostname)."

Note: On ubuntu with lsb, not /etc/init.d/, see
/etc/init.d/hostname and
$ cat /etc/init/hostname.conf

The /etc/hostname should only contain the hostname (not the domain part)
"Edit /etc/hostname for permanent change."

"   -b, --boot
              Always set a hostname; this allows the file specified by
-F to be non-existant or empty, in which case the  default  hostname
localhost will be used if none is yet set."

"The FQDN of the system is the name that the resolver(3) returns for
the host name. Therefore it depends on the configuration (usually in
/etc/host.conf) how you can change it. Usually (if the hosts file is
parsed before DNS or NIS) you can change it in /etc/hosts."

Example, see man nsswitch.conf:
$ cat /etc/nsswitch.conf
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

Also check man hosts, man man resolv.conf

Hope it helps, Thufir
Use the -f option for hostname (or -A) and get back. hostname with no
options SHOULD just return "tleilax", nothing else.


More information about the ubuntu-users mailing list