There has been a fair amount of confusion over the difference between the host file and hosts (plural) file. Both files should be in the >system>stcp directory but there the similarity ends.

The hosts file is used for IP address to name resolution. Depending on your configuration you may or may not need a hosts file. If all your names can be resolved via your Domain Name Server (DNS) then the hosts file is optional, although most sites still have one with a “127.0.0.1 localhost” entry.

The host file holds a string containing the name of the system. Ideally, the name is resolvable to an IP address. The host file is read by the “gethostname” function. Many applications call this function to get the host name and fault with a “Bad file number” error when it cannot be found. For example:

>opt>openssl>bin>ssh-keygen
gethostname: Bad file number.

The applications that come to mind are SSH, SSL, and Samba. There are probably others and I guarantee that there will be more in future as we port more applications.

To create the host file just run the hostname command with the system name as an argument. The command will echo the name on the next line:

hostname m17
m17
ready 16:10:12

You will need write access to the >system>stcp directory to create the file. If you run the command without arguments it will display the system name, which you can also do by displaying the file:

hostname
m17
ready 16:14:33

d >system>stcp>host

%azvos#m17_mas>system>stcp>host 12-11-07 16:14:44 mst

m17

ready 16:14:44

You can change the name stored in the file just by running the hostname command with a new name:

hostname #m17
#m17
ready 16:16:24

However, be careful of specifying names with special characters (like % and #) as some applications use the name to create a temporary file and the special characters may prevent that:

gpg --fingerprint
gpg: failed to create temporary file `/SysAdmin/Noah_Davids/.gnupg/._lk40009dd0.#m17.286361238': File name too long or contains invalid characters.