How to Change a Server Hostname via the Linux Command Line
When you need to update your server hostname. This article explains how to change the server hostname using Linux command-line tools.
Sometimes you may come across a server which does not have any control panel setup. You can use the steps mentioned below to change the server hostname.
1) Open the /etc/sysconfig/network file with a text editor. Modify the HOSTNAME= value to match your FQDN host name.
# vi /etc/sysconfig/network
2) Change the host that is associated to your main IP address for your server, this is for internal networking (found at /etc/hosts).
# vi /etc/hosts
3) The 'hostname' command will let you change the hostname on the server that the command line remembers, but it will not actively update all programs that are running under the old hostname.
# hostname new_hostname
4) At this point all the necessary changes that needed to be made have been made, you will want to restart networking on your server to make sure that changes will be persistent on reboot
# /etc/init.d/network restart