Thread: /bin/hostname
View Single Post

  #6  
Old 08-25-2008, 03:56 PM
Default Re: /bin/hostname

On Aug 23, 5:08 pm, ibupro...@painkiller.example.tld (Moe Trin) wrote:
> On Fri, 22 Aug 2008, in the Usenet newsgroup comp.os.linux.networking, in
> article ,
>
> Vwaju wrote:
>
> NOTE: Posting from groups.google.com (or some web-forums) dramatically
> reduces the chance of your post being seen. Find a real news server.
>
> >Bit Twister wrote:
> >> grep jupiter /etc/hosts
> >> 127.0.0.1 localhost.localdomain localhost jupiter
> >> 207.237.37.110 jupiter.obliqueuniverse.org jupiter

>
> >> Why do you have jupiter on more than one line.

>
> >I am working from Linux System Administration (LSA) Adelstein &
> >Lubanovic, O'Reilly, 2007 (p. 14). LSA is a detailed guide to building
> >an internet server on Debian Linux ("sarge"), which is what I am
> >running.

>
> "sarge" (version 3.1) was superseded about a bit over a year ago by
> "etch" (version 4.0). Use the command 'cat /etc/debian_version' to see
> what you are using. (It's a common problem that printed books are
> often dealing with old or even obsolete versions.) Please review the
> section about updating the system before you offer an older system to
> the bad d00ds on the Internet.
>
> >I added the second line (following LSA) because I am building an
> >internet server with a static IP address, and there needs to be a line
> >in /etc/hosts that maps the host and the FQDN to the static IP
> >address.

>
> That is correct, but why is it ALSO a nickname (alias) for localhost?
>
> The concept is that a name appears on one, and only one line in the
> /etc/hosts file. Likewise, an IP address should appear on one line
> only. Many operating systems will _tolerate_ having the same name or
> IP address on multiple lines, but it can give unexpected results.
>
> The 'localhost' alias of 'jupiter' isn't needed. If _ON_ 'jupiter'
> you want to send packets to 'jupiter' or 'jupiter.obliqueuniverse.org',
> the kernel will look at /etc/host.conf (old applications) or
> /etc/nsswitch.conf to see where/how to look up names.
>
> [compton ~]$ grep host /etc/host.conf /etc/nsswitch.conf
> /etc/host.confrder hosts,bind
> /etc/nsswitch.conf:hosts: files nis dns
> [compton ~]$
>
> Here, both files say to check the /etc/hosts file FIRST. Looking in
> your /etc/hosts file, it would find the rcn.com address. But the
> kernel is smart, and knows that this address is one of it's addresses
> and rather than clutter up the wire with useless noise, it would use
> the loopback address - it knows it is talking to itself, not some host
> out on the Internet.
>
> >then /bin/hostnameshould print "myserver" (the hostname w/o the
> >domain name)

>
> >What do you get on your system?

>
> Linux distributions are supposed to follow Linux Standard Base standards,
> and one of those is the Base Core Specification:
>
> ------------------
> Linux Standard Base Core Specification 3.2
>
> Section 15.2 Command Behavior
>
> Name
>
> hostname -- show or set the system's host name
>
> Synopsis
>
> hostname [name]
>
> Description
>
> hostname is used to either display or, with appropriate privileges, set
> the current host name of the system. The host name is used by many
> applications to identify the machine.
>
> When called without any arguments, the program displays the name of the
> system as returned by the gethostname() function.
>
> When called with a name argument, and the user has appropriate
> privilege, the command sets the host name.
>
> Note: It is not specified if the hostname displayed will be a fully
> qualified domain name. Applications requiring a particular format of
> hostname should check the output and take appropriate action.
>
> ------------------
>
> See that note on the end of the requirement? It always is a good idea
> to look at the manual page for commands you are unfamiliar with. As Bit
> shows in his response, you may get different results depending on which
> distribution you are using. And by the way, my systems also return the
> FQDN.
>
> Old guy


Thank you for the helpful pointers, Old Guy. I had read the man page
for hostname, but was not aware of the Linux Standard Base Core
Specification 3.2)

Best Regards,
Vwaju
NYC
Reply With Quote