== Beware of using Linux's _hostname -s_ switch The _hostname_ program has a common switch, _-s_, which is documented (in the Linux version) as: > - _-s, --short_: Display the short host name. This is the host name > cut at the first dot. Although you would not expect it from this description, running '_hostname -s_' will do a _gethostbyname()_ and thus often a DNS lookup in most Linux versions of _hostname_. This can of course fail if your DNS is not working, which winds up with the very peculiar result of _hostname_ failing. And all of this because you innocently decided to trim out any dots that might be present using the most obvious and easiest approach. (Most scripts don't cope very well with this, partly because the Bourne shell makes it annoyingly difficult to deal with programs failing in command substitutions and partly because come on, who expects _hostname_ to fail?) Red Hat Enterprise 5, Fedora 8, Ubuntu 6.06 and Ubuntu 8.04 have versions of _hostname_ that behave this way. Fedora 11 has a version that does not, because [[someone filed a bug about it https://bugzilla.redhat.com/show_bug.cgi?id=531702]]; unfortunately I can't tell if this has been fixed upstream or if an upstream bug has been filed (or if it would be useful to do so). The sad conclusion is that for the next several years, if you need the local hostname without any dots on it you should write something like: > _hostname | sed 's/\..*//'_ instead of using the shorter, nicer _hostname -s_. (We found this out the hard way last night, when we had some sort of network issue that made our DNS servers unreachable to some machines while some of our status check scripts were running.)