Hostname funniness

Lorenzo E. Danielsson lorenzo at aponkye.com
Wed Nov 17 08:39:53 CST 2004


On Wed, 2004-11-17 at 14:48 +0100, Dennis Kaarsemaker wrote:
> On Wed, 2004-11-17 at 12:49 +0000, Lorenzo E. Danielsson wrote:
> > Ubuntu (Hoary):
> > % hostname
> > my.hostname.net
> > % hostname -s
> > localhost
>
> My quess is that hostname (or the gethostname() function) reads the
> description from /etc/hostname
> hostname -s or hostname --fqdn read their data from /etc/hosts
> 
> For me this happens:
> $ hostname
> raptor
> $ hostname -s
> localhost
> $ hostname --fqdn
> localhost.localdomain
> $ cat /etc/hostname
> raptor
> $ cat /etc/hosts
> 127.0.0.1	localhost.localdomain	localhost	raptor
> 
> Reading the manpage for hostname confirms this.
> -- 

Aarrghh! You're absolutely right. I read the BSD manpage for hostname.. 
I can understand why BSD and Ubuntu behave differently, but then why
does Gentoo behave the right way (the BSD way)? I don't have access to
the Gentoo box atm, but I'm quite sure hosts looks something like this:

127.0.0.1       localhost.localdomain localhost
192.168.1.120	my.host.name my

In that case, the gentoo box should respond to hostname -s with
localhost. But I know that it gives me 'my'..

Anyways, that's a minor issue. I'll figure that out when I have access
to my box.

++Lorenzo;

> Dennis K.
>   And that's the way the cookie crumbles!
> 
> 




More information about the ubuntu-devel mailing list