Setting the system's hostname is a simple matter of using the hostname command. If you are on a network, your hostname should be the full hostname of your machine, such as goober.norelco.com. If you are not on a network of any kind, you can choose an arbitrary host and domainname, such as loomer.vpizza.com, shoop.nowhere.edu, or floof.org.
When setting the hostname, the hostname must appear in the file /etc/hosts, which assigns an IP address to each host. Even if your machine is not on a network, you should include your own hostname in /etc/hosts.
For example, if you are not on a TCP/IP network, and your hostname is floof.org, simply include the following line in /etc/hosts:
127.0.0.1 floof.org localhost
This assigns your hostname, floof.org, to the loopback address 127.0.0.1 (used if you're not on a network). The localhost alias is also assigned to this address.
If you are on a TCP/IP network, however, your real IP address and hostname should appear in /etc/hosts. For example, if your hostname is goober.norelco.com, and your IP address is 220.127.116.11, add the following line to /etc/hosts:
If your hostname does not appear in /etc/hosts, you will not be able to set it.
To set your hostname, simply use the hostname command. For example, the command
# hostname -S goober.norelco.com
sets the hostname to goober.norelco.com. In most cases, the hostname command is executed from one of the system startup files, such as /etc/rc or /etc/rc.local. Edit these two files and change the hostname command found there to set your own hostname; upon rebooting the system the hostname will be set to the new value.