How to change the server's name.
Posted by admin on 11 September 2009 11:13 PM
Running as root:|
# hostname acme.dev.nul
(assuming you wish to name the host: 'acme.dev.nul'), and adding or editting the "HOSTNAME=" line in:
appropriately will do the trick.
Some applications also want to be able to do a lookup of hostname to IP, and for that purpose, editting /etc/hosts is often done. Another and better solution to that second question is to place the server in an environment with a working forward and reverse DNS and letting the initscripts manage the matter. We just answer the question about changing a server's name here.
See also the file documentation concerning the initscripts, which in the first instance handle the setting of the server name based on the values found in /etc/sysconfig/network or /etc/sysconfig/network-scripts/ifcfg-ethX:
# rpm -ql initscripts | grep doc