SuSE Linux: All versions
hostname
and
domainname
, on different UNIX[tm] based systems you get
--- different answers depending on the and the system (e.g.: AIX,
HP-UX, OSF/1, IRIX) --- back.
hostname
traditionally returns either the system's short
name or sometimes the full DNS domain name. This depends totally on
how the system is configured by your SysAdmin. DNS is the
abbreviation for domain name server.
The command domainname
often delivers either nothing or
the usual domainname. More exceptionally, but still possible; The
delivered domainname is different from the domain used in the
hostname.
The command hostname
looks in
/etc/resolve.conf
or directly in /etc/hosts
for the giveen name thus providing the fully qualified hostname.
Under Linux the command hostname -f
always returns the
fully qualified hostname and the command hostname -s
always the short hostname. An entry in /etc/hosts
always
resembles the pattern:
IP_Address Full_qualified_Hostname NicknameMore nicknames can be declared, but only the first name after the IP address is the system's fully qualified name and this one must correspond to an eventual available name server! In few words: The system's fully qualified name is either defined by
/etc/hosts
or by a name server.
More confusing is the command domainname
. By invoking
it, the domainname used in the fully qualified hostname (the so-called
DNS domain, DNS comes from domain name server)
can appear --- however this must not be so!
domainname
returns exclusively the NIS system's
used domain, that is, the yellow pages system's domain
for the password distribution in a NIS domain.
Such a NIS domain can be identical to the domain used in the
fully qualified hostname
--- in many NIS systems another name is used for the
NIS domain.
ypdomainname
. It always returns the same output as
domainname
: the NIS domain's name. With it, the
NIS domain can be set either with the command
domainname
or ypdomainname
. Without it the
system must be integrated in a NIS domain.
If you would like to know your DNS domain's name, as well as the fully qualified hostname's domain, either execute the command:
hostname -dor
dnsdomainname.
/sbin/init.d/boot
:
test -n "$FQHOSTNAME" && hostname $FQHOSTNAMEto:
test -n "$FQHOSTNAME" && hostname ${FQHOSTNAME%%.*}After this change and a reboot, the command
hostname
returns the system's short hostname and hostname -f
the
full qualified hostname.